body: const Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: WebView(
initialUrl: "https://xxxx",
navigationDelegate: (navigation) {
return NavigationDecision.navigate;
},
),
),
When compile, an error happened.
lib/main.dart:84:31: Error: Not a constant expression.
navigationDelegate: (navigation) {
^^^^^^^^^^^^
When I use flutter-2.2.0 and webview_flutter-2.0.13, the code above works fine. But after i upgraded flutter to 2.5.2 and webview_flutter to 2.0.13, the error happened.
environment(flutter 2.5.2):
environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
webview_flutter: 2.1.1
You are trying to use a const constructor of the Center widget with not constant parameters.
By creating a widget with a const constructor, you specify that all of its fields will be defined at compile-time.
So, in your case, you need to remove const before the Center widget, because this is not constant:
navigationDelegate: (navigation) {
return NavigationDecision.navigate;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With