Martin Wittick
Martin Wittick

Reputation: 503

How to prevent flutter_webview from reloading rotatiting screen?

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?

Upvotes: 0

Views: 186

Answers (1)

heyom
heyom

Reputation: 342

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

Upvotes: 0

Related Questions