0

I'm using webview_flutter plugin like below:

@override
      Widget build(BuildContext context) {
         return Scaffold(
            body: WebView(
                      gestureNavigationEnabled: true,
                      initialUrl: link,
                      javascriptMode: JavascriptMode.unrestricted,
                      navigationDelegate: (NavigationRequest request) {
                        return NavigationDecision.prevent;
                      },
                    )
         );
    }

And whenever I change the screen orientation the pageView reloads the webPage. How can I prevent this reload?

Martin Wittick
  • 433
  • 1
  • 4
  • 14

1 Answers1

0

Basically your webpage is being re-build to accomodate your landscape view of your mobile device You can use this to keep it alive by the below code

Try this should work:

new WebviewScaffold(
          url: "https://flutter.dev/",
          withLocalStorage: true,
          withJavascript: true
      ),

Using this

withLocalStorage: true,
withJavascript: true

for your code to be alive

heyom
  • 322
  • 2
  • 7
  • I'm sorry but I'm using webview_flutter plugin not flutter_webview_plugin, so there is no WebViewScaffold class in it, I should've been more clear, sorry again. – Martin Wittick Sep 03 '21 at 02:35