英文:
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
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论