Flutter tapping textbox inside the WebView makes parent widget to refresh in iOS only

209 Views Asked by At

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

1

There are 1 best solutions below

0
Sandun Perera On

Found the issue and the solution.

Previous route (screen) calls Navigator.pushAndRemoveUntil(...) to navigate to the WebView screen route. I guess, since there are no navigation history, WebView widget go nuts.

I replaced the previous route (screen), to call Navigator.push(...) instead, and the issue is gone.