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) {
  super.didPop(route, previousRoute);
  final history = nav.navigationHistory.val;
  if (history.isNotEmpty) {
    final updated = List<NeuronNavigationEntry>.from(history)..removeLast();
    nav.navigationHistory.emit(updated);
    nav._historyIndex = updated.length - 1;
    nav.canGoForward.emit(false);
  }
  if (previousRoute?.settings.name != null) {
    final entry = nav.navigationHistory.val.isNotEmpty
        ? nav.navigationHistory.val.last
        : null;
    if (entry != null) {
      nav.currentRoute.emit(entry.state);
    }
  }
}