@@ -11,12 +11,12 @@ class FlutterBkashView extends StatefulWidget {
11
11
final String cancelledCallbackURL;
12
12
13
13
const FlutterBkashView ({
14
- Key ? key,
14
+ super . key,
15
15
required this .bkashURL,
16
16
required this .successCallbackURL,
17
17
required this .failureCallbackURL,
18
18
required this .cancelledCallbackURL,
19
- }) : super (key : key) ;
19
+ });
20
20
21
21
@override
22
22
FlutterBkashViewState createState () => FlutterBkashViewState ();
@@ -39,8 +39,7 @@ class FlutterBkashViewState extends State<FlutterBkashView> {
39
39
// },
40
40
// onPageStarted: (String url) {},
41
41
// onPageFinished: (String url) {},
42
- onWebResourceError: (WebResourceError error) =>
43
- Navigator .of (context).pop (BkashPaymentStatus .failed),
42
+ onWebResourceError: (WebResourceError error) => Navigator .of (context).pop (BkashPaymentStatus .failed),
44
43
onNavigationRequest: (NavigationRequest request) {
45
44
if (request.url.contains ("bkash.com" )) {
46
45
//sendbox starts with sandbox.payment.bkash.com and live starts with payment.bkash.com
@@ -70,13 +69,18 @@ class FlutterBkashViewState extends State<FlutterBkashView> {
70
69
71
70
@override
72
71
Widget build (BuildContext context) {
73
- return WillPopScope (
74
- onWillPop: () async {
75
- if (await _webViewController.canGoBack ()) {
76
- await _webViewController.goBack ();
72
+ return PopScope (
73
+ canPop: false ,
74
+ onPopInvokedWithResult: (didPop, result) async {
75
+ if (! didPop) {
76
+ if (await _webViewController.canGoBack ()) {
77
+ await _webViewController.goBack ();
78
+ } else {
79
+ if (context.mounted) {
80
+ Navigator .of (context).pop (BkashPaymentStatus .canceled);
81
+ }
82
+ }
77
83
}
78
-
79
- return false ;
80
84
},
81
85
child: Scaffold (
82
86
backgroundColor: Colors .white,
@@ -87,8 +91,7 @@ class FlutterBkashViewState extends State<FlutterBkashView> {
87
91
leading: IconButton (
88
92
icon: const Icon (Icons .arrow_back),
89
93
color: Colors .white,
90
- onPressed: () =>
91
- Navigator .of (context).pop (BkashPaymentStatus .canceled),
94
+ onPressed: () => Navigator .of (context).pop (BkashPaymentStatus .canceled),
92
95
),
93
96
title: const Text ('bKash Checkout' )),
94
97
body: WebViewWidget (controller: _webViewController),
0 commit comments