如何在flutter WebView中当用户导航到特定URL时显示snackbar
以及如何在webview中添加按钮以在webview内的页面之间导航
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Web view'),
),
body: WebViewWidget(
controller: WebViewController()
..enableZoom(false)
..setNavigationDelegate(NavigationDelegate(
onNavigationRequest: (request) {
if (request.url.startsWith(widget.returnUrl)) {
print("Hello");
return NavigationDecision.prevent;
}
return NavigationDecision.navigate;
},
))
..setJavaScriptMode(JavaScriptMode.unrestricted)
..loadRequest(
Uri.parse('https://google.com/'),
)
)
);
}
}
字符串
1条答案
按热度按时间0s7z1bwu1#
解决方法:
字符串
结果: