pop method

void pop()

Removes the topmost route from the stack, and also removes it as a child of the Router.

The method calls Route.didPop for the route that was removed.

It is an error to attempt to pop the last remaining route on the stack.

Implementation

void pop() {
  assert(
    _routeStack.length > 1,
    'Cannot pop the last route from the Router',
  );
  final route = _routeStack.removeLast();
  _adjustRoutesOrder();
  _adjustRoutesVisibility();
  route.didPop(_routeStack.last);
  route.removeFromParent();
}