Created
November 11, 2019 06:18
-
-
Save vaibhav93/6c37d1ebe5f1cc9717b8d4ec88dc3907 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart'; | |
class WebViewContainer extends StatefulWidget { | |
final url; | |
WebViewContainer(this.url); | |
@override | |
createState() => _WebViewContainerState(); | |
} | |
class _WebViewContainerState extends State<WebViewContainer> { | |
_WebViewContainerState(); | |
@override | |
void initState() { | |
final flutterWebviewPlugin = new FlutterWebviewPlugin(); | |
super.initState(); | |
flutterWebviewPlugin.onUrlChanged.listen((String url) { | |
print(url); | |
if (url.contains("payment_success")) { | |
flutterWebviewPlugin.close(); | |
Navigator.of(context).pushNamedAndRemoveUntil('/payment_success', ModalRoute.withName('/home')); | |
} else if(url.contains("payment_pending")) { | |
flutterWebviewPlugin.close(); | |
Navigator.of(context).pushReplacementNamed('/payment_pending'); | |
} | |
else if(url.contains("payment_failure")) { | |
flutterWebviewPlugin.close(); | |
Navigator.of(context).pushReplacementNamed('/payment_failure'); | |
} | |
}); | |
} | |
@override | |
Widget build(BuildContext context) { | |
print(widget.url); | |
return SafeArea( | |
child: WebviewScaffold( | |
url: widget.url, | |
hidden: false, | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment