Skip to content

Instantly share code, notes, and snippets.

@vaibhav93
Created November 11, 2019 06:18
Show Gist options
  • Save vaibhav93/6c37d1ebe5f1cc9717b8d4ec88dc3907 to your computer and use it in GitHub Desktop.
Save vaibhav93/6c37d1ebe5f1cc9717b8d4ec88dc3907 to your computer and use it in GitHub Desktop.
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