fixed pop scope exit

This commit is contained in:
Thibault Deckers 2023-11-29 22:19:25 +01:00
parent 90d836cf37
commit 4c1c516206

View file

@ -1,3 +1,4 @@
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
// as of Flutter v3.3.10, the resolution order of multiple `WillPopScope` is random // as of Flutter v3.3.10, the resolution order of multiple `WillPopScope` is random
@ -21,7 +22,12 @@ class AvesPopScope extends StatelessWidget {
final shouldPop = handlers.fold(true, (prev, v) => prev ? v(context) : false); final shouldPop = handlers.fold(true, (prev, v) => prev ? v(context) : false);
if (shouldPop) { if (shouldPop) {
Navigator.of(context).pop(); if (Navigator.canPop(context)) {
Navigator.maybeOf(context)?.pop();
} else {
// exit
SystemNavigator.pop();
}
} }
}, },
child: child, child: child,