打开url并在flutter中向应用程序提交数据



我有一个要求,在应用程序中,我需要将用户导航到webview(网站),并且会有一个带有5个字段的表单,一旦表单提交了一个要传递给应用程序的标志,应用程序应该基于该标志工作。那么如何实现呢

我已经检查了,有一个url_launcher或webview_flutter,但我不知道如何重定向应用程序一旦表单提交到网站

我不完全确定我是否理解了这个问题。但这是可以做的。

  1. 在webview中打开url
  2. 现在你应该听webview状态的变化。必须有一个听众。假设监听器是webViewStateChanged,它会给你webview的状态。

然后你可以检查

void webViewStateChanged(WebViewStateChanged newState) async {
if (newState.type != WebViewState.finishLoad ||
newState.url != desiredURL) {
return;
}
// At this point, you want to return to your app. If you need data from 
// website, you can do so by accessing cookies of webview. 
// Now you are back to the app, you can pop/replace the webview whatever
// is your requirement. 

相关内容

最新更新