Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changing url has no effect on existing WebviewScaffold. #163

Closed
sma opened this issue Aug 17, 2018 · 1 comment
Closed

changing url has no effect on existing WebviewScaffold. #163

sma opened this issue Aug 17, 2018 · 1 comment

Comments

@sma
Copy link

sma commented Aug 17, 2018

My setup uses two WebviewScaffolds with different urls in such a way that Flutter will not rebuild the WebviewScaffold widget but simply change the properties. Neither initState nor dispose is called and therefore the plugin will not notice that the URL has been changed. Please also implement didUpdateWidget to deal with that fact.

The implementation below seems to work but I don't know whether it is okay to simply copy the rather longish call from build. I tried to call webviewReference.reloadUrl but that didn't work.

  @override
  void didUpdateWidget(WebviewScaffold oldWidget) {
    super.didUpdateWidget(oldWidget);
    if (oldWidget.url != widget.url) {
      webviewReference.launch(widget.url,
        headers: widget.headers,
        withJavascript: widget.withJavascript,
        clearCache: widget.clearCache,
        clearCookies: widget.clearCookies,
        enableAppScheme: widget.enableAppScheme,
        userAgent: widget.userAgent,
        rect: _rect,
        withZoom: widget.withZoom,
        withLocalStorage: widget.withLocalStorage,
        withLocalUrl: widget.withLocalUrl,
        scrollBar: widget.scrollBar);
    }
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants