Skip to content

Commit 2985ea1

Browse files
committed
dart/flutter code analyzed with prepare for published
1 parent 30e583c commit 2985ea1

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

example/test/widget_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import 'package:flutter/material.dart';
99
import 'package:flutter_test/flutter_test.dart';
1010

11-
import '../lib/main.dart';
11+
import 'package:example/main.dart';
1212

1313
void main() {
1414
testWidgets('Counter increments smoke test', (WidgetTester tester) async {

lib/src/flutter_bkash_view.dart

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ class FlutterBkashView extends StatefulWidget {
1111
final String cancelledCallbackURL;
1212

1313
const FlutterBkashView({
14-
Key? key,
14+
super.key,
1515
required this.bkashURL,
1616
required this.successCallbackURL,
1717
required this.failureCallbackURL,
1818
required this.cancelledCallbackURL,
19-
}) : super(key: key);
19+
});
2020

2121
@override
2222
FlutterBkashViewState createState() => FlutterBkashViewState();
@@ -39,8 +39,7 @@ class FlutterBkashViewState extends State<FlutterBkashView> {
3939
// },
4040
// onPageStarted: (String url) {},
4141
// onPageFinished: (String url) {},
42-
onWebResourceError: (WebResourceError error) =>
43-
Navigator.of(context).pop(BkashPaymentStatus.failed),
42+
onWebResourceError: (WebResourceError error) => Navigator.of(context).pop(BkashPaymentStatus.failed),
4443
onNavigationRequest: (NavigationRequest request) {
4544
if (request.url.contains("bkash.com")) {
4645
//sendbox starts with sandbox.payment.bkash.com and live starts with payment.bkash.com
@@ -70,13 +69,18 @@ class FlutterBkashViewState extends State<FlutterBkashView> {
7069

7170
@override
7271
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+
}
7783
}
78-
79-
return false;
8084
},
8185
child: Scaffold(
8286
backgroundColor: Colors.white,
@@ -87,8 +91,7 @@ class FlutterBkashViewState extends State<FlutterBkashView> {
8791
leading: IconButton(
8892
icon: const Icon(Icons.arrow_back),
8993
color: Colors.white,
90-
onPressed: () =>
91-
Navigator.of(context).pop(BkashPaymentStatus.canceled),
94+
onPressed: () => Navigator.of(context).pop(BkashPaymentStatus.canceled),
9295
),
9396
title: const Text('bKash Checkout')),
9497
body: WebViewWidget(controller: _webViewController),

0 commit comments

Comments
 (0)