Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
332 views
in Technique[技术] by (71.8m points)

Open url and submitted data to app in flutter

I have a requirement ,in app I need to navigate the user to webview (website) and there will be a form with 5 fields and once the form is submitted a flag to be passed to app and app should work based on the flag .. So how it can be achieved

I have checked that there is a url_launcher or webview_flutter but i don know how to redirect the app once the form is submitted in website

question from:https://stackoverflow.com/questions/65939285/open-url-and-submitted-data-to-app-in-flutter

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I am not entirely sure if I understood the problem. But here is what can be done.

  1. Open url in webview.
  2. Now you should listen to webview state change. There must be a listener for this. say the listener is webViewStateChanged which will give you the state of webview.

Then you can check like

  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. 


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...