popStack method

  1. @override
void popStack([
  1. NavigationContext? navigationContext
])
override

Removes the entire current navigation stack and navigates back to the last route of the previous stack. Throws an error if there's only one navigation stack.

Returns a Future that resolves as soon as the navigation completes.

Implementation

@override
void popStack([NavigationContext? navigationContext]) {
  if (_history.length == 1) {
    // pops the whole RootNavigator from its parent navigator
    return Navigator.of(context).pop();
  }
  _thisNavigatorKey.currentState!.pop();
  _history.removeLast();
  _history.last.setNavigationContext(navigationContext);
}