didPop method

  1. @override
void didPop(
  1. Route route,
  2. Route? previousRoute
)
override

The Navigator popped route.

The route immediately below that one, and thus the newly active route, is previousRoute.

Implementation

@override
void didPop(Route route, Route? previousRoute) {
  final ctx = navigator?.context;
  if (ctx == null) return;
  final nav = Provider.of<NavigationState>(ctx, listen: false);

  final prevArgs = previousRoute?.settings.arguments as Map<String, dynamic>?;
  final path = prevArgs?['routePath'] as String? ?? '';
  if (path.isNotEmpty) {
    nav.removeUntil(path);
  }
}