我有一个Flutter应用程序,其中包含一个Web视图,可以浏览特定的URL。该Web视图包含一个表单,当填写并提交表单后,Web视图根据用户的表单填写将其重定向到结果URL。
我正在使用InAppWebView插件用于Web视图。当我的重定向URL被访问时,我想导航到我的DashboardScreen屏幕。但是我无法导航到该屏幕,请帮忙解决。以下是我的构建方法:
我正在使用InAppWebView插件用于Web视图。当我的重定向URL被访问时,我想导航到我的DashboardScreen屏幕。但是我无法导航到该屏幕,请帮忙解决。以下是我的构建方法:
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
title: Text("MyApp"),
),
body: InAppWebView(
initialUrl: "myURL",
onWebViewCreated: (InAppWebViewController controller) {
_webViewController = controller;
},
onLoadStop: (InAppWebViewController controller, String url) async {
if (url.startsWith("redirectURL")) {
// get your token from url
Navigator.pop(context);
Navigator.pushReplacement(context,
MaterialPageRoute(builder: (context) => DashboardScreen()));
}
},
),
),
);
}