Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
chunhtai committed Aug 14, 2023
1 parent 69e6e35 commit 55e4c87
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/go_router/lib/src/delegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class GoRouterDelegate extends RouterDelegate<RouteMatchList>
}

/// For use by the Router architecture as part of the RouterDelegate.
// This class avoid using async to make sure the route is processed
// This class avoids using async to make sure the route is processed
// synchronously if possible.
@override
Future<void> setNewRoutePath(RouteMatchList configuration) {
Expand All @@ -177,7 +177,6 @@ class GoRouterDelegate extends RouterDelegate<RouteMatchList>
}
}
if (indexOfFirstDiff < currentConfiguration.matches.length) {
// Appends onExit future to the result future and return early if
final List<GoRoute> exitingGoRoutes = currentConfiguration.matches
.sublist(indexOfFirstDiff)
.map<RouteBase>((RouteMatch match) => match.route)
Expand All @@ -197,6 +196,10 @@ class GoRouterDelegate extends RouterDelegate<RouteMatchList>
return _setCurrentConfiguration(configuration);
}

/// Calls [GoRoute.onExit] starting from the index
///
/// The returned future resolves to true if all routes below the index all
/// return true. Otherwise, the returned future resolves to false.
static Future<bool> _callOnExitStartsAt(int index,
{required BuildContext navigatorContext, required List<GoRoute> routes}) {
if (index < 0) {
Expand All @@ -207,6 +210,7 @@ class GoRouterDelegate extends RouterDelegate<RouteMatchList>
return _callOnExitStartsAt(index - 1,
navigatorContext: navigatorContext, routes: routes);
}

Future<bool> handleOnExitResult(bool exit) {
if (exit) {
return _callOnExitStartsAt(index - 1,
Expand Down

0 comments on commit 55e4c87

Please sign in to comment.