How can I redirect back to Flutter App from URL?

匆匆过客 提交于 2020-12-15 06:16:30

问题


I am integrating paytabs payment gateway in my flutter application. It opens a payment page in in app browser. When the transaction is completed, it redirects to a return_url. I want to redirect back to my app, so that I can do something after the payment has been processed.

How can this be accomplished?


回答1:


I found a solution and it worked for me!

InAppWebView

In flutter to open the paytabs transaction page. When the transaction is successful, it redirects me to a return_url. InAppWebView has a method

onLoadStart: (InAppWebViewController controller, String url)

In this method, I checked if the returl_url == url and redirected to my app and closed the InAppWebView accordingly.

onLoadStart: (InAppWebViewController controller, String url) {
          setState(() {
            _con.url = url;
          });
          if (url == "return_url") {
            //close the webview
            _con.webView.goBack();

            //navigate to the desired screen with arguments
            Navigator.of(context).pushReplacementNamed('/OrderSuccess',
                arguments:
                    new RouteArgument(param: 'Credit Card (Paytabs)'));
          }
        },


来源:https://stackoverflow.com/questions/64315924/how-can-i-redirect-back-to-flutter-app-from-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!