I have a WebView widget as a child widget of a Container widget. Tapping on the textbox field inside the WebView widget makes the Container to reload from initState() level.
Container(
child:
WebView(
initialUrl: 'about:blank',
onWebViewCreated: (controller) async {
_webviewController = controller;
await _loadHtmlFromUrl(context);
},
javascriptMode: JavascriptMode.unrestricted,
onPageFinished: (finish) {
if (this.mounted && this._isLoading == true) {
setState(() {
this._isLoading = false;
});
}
},
),
);
WebView is loaded with a dynamic Url.
User is unable to type inside the textbox as it keeps on reloading when tapping on it.
Flutter SDK 3.3.7
WebView v2.8.0
How can I fix this? TIA
Found the issue and the solution.
Previous route (screen) calls
Navigator.pushAndRemoveUntil(...)to navigate to theWebViewscreen route. I guess, since there are no navigation history,WebViewwidget go nuts.I replaced the previous route (screen), to call
Navigator.push(...)instead, and the issue is gone.