Skip to content

changing url has no effect on existing WebviewScaffold. #163

@sma

Description

@sma

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);
    }
  }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions