“Undefined name WebView in flutter” 可以翻译为 “在Flutter中未定义 WebView 名称”。

huangapple go评论62阅读模式
英文:

Undefined name WebView in flutter

问题

I'm now having some trouble regarding Undefined name WebView. I'm using minSdkVersion 20 in build.gradle. This is what I have and this error only happened when I upgraded my flutter version to 3.7.11 today.

pubspec.yaml

webview_flutter: ^4.1.0

webviewpage.dart

import 'package:webview_flutter/webview_flutter.dart';

......
void initState() {
    super.initState();
    if (Platform.isAndroid) WebView.platform = AndroidWebView(); // Webview undefined error
}

....
child: WebView( // The method 'WebView' isn't defined for the type '_WebViewPageState'
           zoomEnabled: false,

How can I possibly resolve this error?

英文:

I'm now having some trouble regarding Undefined name WebView. I'm using minSdkVersion 20 in build.gradle. This is what I have and this error only happened when I upgraded my flutter version to 3.7.11 today.

pubspec.yaml

webview_flutter: ^4.1.0

webviewpage.dart

import 'package:webview_flutter/webview_flutter.dart';

.....
void initState() {
    super.initState();
    if (Platform.isAndroid) WebView.platform = AndroidWebView(); // Webview undefined error
}

....
child: WebView( // The method 'WebView' isn't defined for the type '_WebViewPageState'
           zoomEnabled: false,

How can I possibly resolve this error?

答案1

得分: 1

这是因为 webview_flutter: ^4.1.0 不再使用 WebView 类。

第一个可能的解决方案是将 webview_flutter 降级到版本 3.0.4。

第二个解决方案是根据这里描述的方式更新您的代码,以适用于当前版本的 webview_flutter

英文:

This is because the webview_flutter: ^4.1.0 does not use WebView class anymore.

First possible solution is downgrading your webview_flutter to version 3.0.4

Second solution: you have to update your code as it described here for the actual version of webview_flutter.

huangapple
  • 本文由 发表于 2023年4月19日 16:41:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/76052429.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定