Skip to content

Commit 7b93500

Browse files
committed
BuildContext propagation for onPopPage
1 parent cd2a4d4 commit 7b93500

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/src/url_router.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class UrlRouter extends RouterDelegate<String> with ChangeNotifier, PopNavigator
2323
final Widget Function(UrlRouter router, Widget navigator)? builder;
2424

2525
/// Optionally provide a way for the parent to implement custom `onPopPage` logic.
26-
final PopPageCallback? onPopPage;
26+
final bool Function(BuildContext context, Route<dynamic> route, dynamic result)? onPopPage;
2727

2828
/// Optionally invoked just prior to the location being changed.
2929
/// Allows a parent class to protect or redirect certain routes. The callback can return the original url to allow the location change,
@@ -97,7 +97,9 @@ class UrlRouter extends RouterDelegate<String> with ChangeNotifier, PopNavigator
9797
this.context = context;
9898
Widget content = Navigator(
9999
key: _navKey,
100-
onPopPage: onPopPage ?? handlePopPage,
100+
onPopPage: onPopPage != null
101+
? (route, settings) => onPopPage!(context, route, settings)
102+
: handlePopPage,
101103
pages: pages,
102104
);
103105
if (builder != null) {

0 commit comments

Comments
 (0)