Get current URL in webview
2,051
Is it enough for your reload button to use Future<Null> reload();
? This seems to reload the current url. So you don't have to set the url explicit.
You have to change the call of the function to
onPressed: () => flutterWebviewPlugin.reload(), // this is reloading the url that was provided to webview, not the current URL. )
Author by
Strange
Updated on December 09, 2022Comments
-
Strange over 1 year
I am using Flutter WebView Plugin to create
webview
in Flutter app. I have added areload
icon inside theappBar
. In order to make thereload
icon functional, I want to get thecurrent URL
fromwebview
.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(), ), ), ) }, );
Is there any function to get the
current URL
fromwebview
or any other method? Please help.