I use webview_flutter plugin in my flutter app. How can I add header parameter when url changes and how can I and how can I track url change? That's my code. I tried to do it using a loadurl in navigationDelegate, but it doesn't work. How can I do that? Please, help
String URL = 'https://...../login-app?authkey=${globals.authkey}&test=1';
WebViewController _webViewController;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: new AppBar(),
body: WebView(
// initialUrl: 'https://...../login-app?authkey=${globals.authkey}',
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController webViewController) {
_controller.complete(webViewController);
webViewController.loadUrl(URL,headers: {"SB-app": "iphone"},);
},
navigationDelegate: (NavigationRequest request) async {
print('allowing navigation to $request');
if(request.url.contains('driver/chat') || request.url.contains('driver/on-map') || request.url.contains('driver/passanger-form') || request.url.contains('driver/login')) {
_webViewController.loadUrl(request.url, headers: {"SB-app": "iphone"});
}
return NavigationDecision.navigate;
},
onPageStarted: (String url) async {
print('Page started loading: $url');
},
onPageFinished: (String url) async {
print('Page finished loading: $url');
},