简体   繁体   English

如何在 Flutter 中的某个时刻关闭 Webview

[英]How to close the Webview at some point in Flutter

I'm using url_launcher to show the webview inside the app to do the payment, After completion of the payment I have to navigate back to the previous screen.我正在使用url_launcher在应用程序内显示 webview 以进行付款,付款完成后我必须导航回上一个屏幕。 Is there any possibility to do this?有没有可能做到这一点? Should it be handled from webview or mobile app?应该从 webview 还是移动应用程序处理?

This is the way that im using to show webview这是我用来显示 webview 的方式

_launchURL(onboardingLink) async {
   await canLaunch(onboardingLink)? 
     await launch(onboardingLink,
                  enableJavaScript: true,
                  forceWebView: true)
            : throw 'Could not launch $onboardingLink';
}

USE THIS用这个

_onUrlChanged =
    flutterWebviewPlugin.onUrlChanged.listen((String url) async {
  if (mounted) {
    //print("URL changed: $url");
    if (url.startsWith(paymentSuccessUrl)) {
        // handle success case
    } else if (if (paymentCancelUrl)) {
        // Handle cancel case
    }
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM