From 4c1c51620643129cc93929896df11c1c6096bed4 Mon Sep 17 00:00:00 2001 From: Thibault Deckers Date: Wed, 29 Nov 2023 22:19:25 +0100 Subject: [PATCH] fixed pop scope exit --- lib/widgets/common/behaviour/pop/scope.dart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/widgets/common/behaviour/pop/scope.dart b/lib/widgets/common/behaviour/pop/scope.dart index 98d8f79f8..317e59504 100644 --- a/lib/widgets/common/behaviour/pop/scope.dart +++ b/lib/widgets/common/behaviour/pop/scope.dart @@ -1,3 +1,4 @@ +import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; // 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); if (shouldPop) { - Navigator.of(context).pop(); + if (Navigator.canPop(context)) { + Navigator.maybeOf(context)?.pop(); + } else { + // exit + SystemNavigator.pop(); + } } }, child: child,