Skip to content

Commit

Permalink
Fixed MultipleCallbackPopScope not popping the navigator.
Browse files Browse the repository at this point in the history
Fixed `MultipleCallbackPopScope` not closing the app on the last navigation pop
  • Loading branch information
jeroen1602 committed Dec 7, 2023
1 parent c4e7e75 commit afd22ce
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/widgets/multiple_callback_pop_scope.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';

class MultipleCallbackPopScope extends StatefulWidget {
Expand All @@ -22,12 +23,18 @@ class _MultipleCallbackPopScopeState extends State<MultipleCallbackPopScope> {
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,
);
Expand Down

0 comments on commit afd22ce

Please sign in to comment.