Skip to content

Commit 5722db8

Browse files
committed
adjust monitor_pop_route.dart
1 parent ce3af28 commit 5722db8

File tree

2 files changed

+5
-31
lines changed

2 files changed

+5
-31
lines changed

lib/src/helper/pop_monitor/boost_route_monitor.dart

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import 'package:flutter_smart_dialog/src/helper/dialog_proxy.dart';
44
import 'package:flutter_smart_dialog/src/kit/log.dart';
55
import 'package:flutter_smart_dialog/src/kit/view_utils.dart';
66

7+
import 'monitor_pop_route.dart';
8+
79
class BoostRouteMonitor {
810
static BoostRouteMonitor? _instance;
911

@@ -34,7 +36,7 @@ class BoostRouteMonitor {
3436

3537
if (route is ModalRoute) {
3638
willPopCallback() async {
37-
if (_handleSmartDialog()) {
39+
if (MonitorPopRoute.handleSmartDialog()) {
3840
DialogProxy.instance.dismiss(
3941
status: SmartStatus.smart,
4042
closeType: CloseType.back,
@@ -54,32 +56,4 @@ class BoostRouteMonitor {
5456
_monitorRouteMount(route, ++count);
5557
}
5658
}
57-
58-
bool _handleSmartDialog() {
59-
bool shouldHandle = false;
60-
try {
61-
//handle loading
62-
if (SmartDialog.config.loading.isExist) {
63-
return true;
64-
}
65-
66-
//handle dialog
67-
var dialogQueue = DialogProxy.instance.dialogQueue;
68-
69-
if (dialogQueue.isEmpty) {
70-
return false;
71-
}
72-
73-
for (var item in DialogProxy.instance.dialogQueue) {
74-
if (!item.permanent) {
75-
shouldHandle = true;
76-
}
77-
}
78-
} catch (e) {
79-
shouldHandle = false;
80-
debugPrint('SmartDialog back event error:${e.toString()}');
81-
}
82-
83-
return shouldHandle;
84-
}
8559
}

lib/src/helper/pop_monitor/monitor_pop_route.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class MonitorPopRoute with WidgetsBindingObserver {
6161
}
6262

6363
// handle contain system dialog and common condition
64-
if (handleSmartDialog()) {
64+
if (MonitorPopRoute.handleSmartDialog()) {
6565
var lastDialog = DialogProxy.instance.dialogQueue.last;
6666
if (lastDialog.backType == SmartBackType.normal &&
6767
await lastDialog.onBack?.call() != true) {
@@ -78,7 +78,7 @@ class MonitorPopRoute with WidgetsBindingObserver {
7878
return super.didPopRoute();
7979
}
8080

81-
bool handleSmartDialog() {
81+
static bool handleSmartDialog() {
8282
bool shouldHandle = true;
8383
var routeQueue = RouteRecord.instance.routeQueue;
8484
try {

0 commit comments

Comments
 (0)