Получить текущий URL в веб-просмотре - PullRequest
0 голосов
/ 26 февраля 2019

Я использую Flutter WebView Plugin для создания webview в приложении Flutter.Я добавил reload значок внутри appBar.Чтобы сделать значок reload функциональным, я хочу получить current URL из webview.

WebView:

return new MaterialApp(
      theme
        : new ThemeData(
        primaryColor: Color.fromRGBO(58, 66, 86, 1.0), fontFamily: 'Raleway'),
      routes: {
        "/": (_) => new WebviewScaffold(
          url: url,
          appBar: new AppBar(
            title: Text(title),
            actions: <Widget>[
              IconButton(
                icon: Icon(Icons.refresh, color: Color.fromRGBO(255, 255, 255, 1.0),),
                onPressed: () => flutterWebviewPlugin.reloadUrl(url), // this is reloading the url that was provided to webview, not the current URL.
              )
            ],
          ),
          withJavascript: true,
          withLocalStorage: true,
          appCacheEnabled: true,
          hidden: true,
          initialChild: Container(
            child: const Center(
              child: CircularProgressIndicator(),
            ),
          ),
        )
      },
    );

Есть лифункция для получения current URL из webview или любой другой метод?Пожалуйста, помогите.

1 Ответ

0 голосов
/ 26 февраля 2019

Достаточно ли для вашей кнопки перезагрузки значение Future<Null> reload();?Это похоже на перезагрузку текущего URL.Таким образом, вам не нужно устанавливать явный URL.

Вы должны изменить вызов функции на

onPressed: () => flutterWebviewPlugin.reload(), // this is reloading the url that was provided to webview, not the current URL. )
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...