【问题标题】:flutter_inappwebview - How to update URL?flutter_inappwebview - 如何更新 URL?
【发布时间】:2021-07-26 17:25:29
【问题描述】:

我想知道如何使用flutter_inappwebview 包更新我的网址。

这是我的代码:

InAppWebView(
  initialData: InAppWebViewInitialData(
    data: videoName,
  ),

videoName 变量使用setState 更新。但是,InAppWebView 不会显示新的 URL。

如何使用setState 更新videoName

【问题讨论】:

  • 我认为您需要创建一个 InAppWebViewController 并传递给 InAppWebView,然后使用控制器中的 loadUrl。见:inappwebview.dev/docs/in-app-webview/…
  • @JorgeVieira 谢谢。您的建议就是解决方案。

标签: flutter flutter-inappwebview


【解决方案1】:

您有 2 个页面:1)视频页面 2)网页浏览页面

  1. 视频页面如此:

从视频页面通过 webviewpage 中的参数传递 url。

例子:

在视频查看页面中:

Navigator.of(context).push(MaterialPageRoute -> (builder)=> WevViewPage(url);

在网页视图页面中:

WebViewPage 范围无状态 ...

字符串网址;

WebViewPage(this.url); //这里是构造函数

现在显示

InAppWebView(
  initialData: InAppWebViewInitialData(
    data: url,
  ),

【讨论】:

    猜你喜欢
    • 2021-05-08
    • 2021-06-24
    • 2021-02-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-27
    • 1970-01-01
    相关资源
    最近更新 更多