From afd22ce46ab48f3815c612dcc6b14c0f1c0807cf Mon Sep 17 00:00:00 2001 From: Jeroen1602 <1492076+jeroen1602@users.noreply.github.com> Date: Thu, 7 Dec 2023 22:10:37 +0100 Subject: [PATCH] Fixed `MultipleCallbackPopScope` not popping the navigator. Fixed `MultipleCallbackPopScope` not closing the app on the last navigation pop --- lib/widgets/multiple_callback_pop_scope.dart | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/widgets/multiple_callback_pop_scope.dart b/lib/widgets/multiple_callback_pop_scope.dart index d22b0c2..e797221 100644 --- a/lib/widgets/multiple_callback_pop_scope.dart +++ b/lib/widgets/multiple_callback_pop_scope.dart @@ -1,3 +1,4 @@ +import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; class MultipleCallbackPopScope extends StatefulWidget { @@ -22,12 +23,18 @@ class _MultipleCallbackPopScopeState extends State { return PopScope( canPop: false, onPopInvoked: (final bool didPop) { + if (didPop) { + return; + } for (final canPop in widget.canPop) { if (!canPop()) { return; } } Navigator.pop(context); + if (!Navigator.canPop(context)) { + SystemNavigator.pop(animated: true); + } }, child: widget.child, );