bool pop([result ])

Removes the top route in the Navigator's history.

If an argument is provided, that argument will be the return value of the route (see Route.didPop).

If there are any routes left on the history, the top remaining route is notified (see Route.didPopNext), and the method returns true. In that case, if the Navigator has an Navigator.observer, it will be notified as well (see NavigatorObserver.didPop). Otherwise, if the popped route was the last route, the method returns false.

Ongoing gestures within the current route are canceled when a route is popped.

Source

bool pop([dynamic result]) {
  assert(!_debugLocked);
  assert(() { _debugLocked = true; return true; });
  Route<dynamic> route = _history.last;
  assert(route._navigator == this);
  bool debugPredictedWouldPop;
  assert(() { debugPredictedWouldPop = !route.willHandlePopInternally; return true; });
  if (route.didPop(result ?? route.currentResult)) {
    assert(debugPredictedWouldPop);
    if (_history.length > 1) {
      setState(() {
        // We use setState to guarantee that we'll rebuild, since the routes
        // can't do that for themselves, even if they have changed their own
        // state (e.g. ModalScope.isCurrent).
        _history.removeLast();
        _history.last.didPopNext(route);
        config.observer?.didPop(route, _history.last);
        route._navigator = null;
      });
    } else {
      assert(() { _debugLocked = false; return true; });
      return false;
    }
  } else {
    assert(!debugPredictedWouldPop);
  }
  assert(() { _debugLocked = false; return true; });
  _cancelActivePointers();
  return true;
}