didPop method

  1. @override
bool didPop (
  1. T result
)
inherited

A request was made to pop this route. If the route can handle it internally (e.g. because it has its own stack of internal state) then return false, otherwise return true (by return the value of calling super.didPop). Returning false will prevent the default behavior of NavigatorState.pop.

When this function returns true, the navigator removes this route from the history but does not yet call dispose. Instead, it is the route's responsibility to call NavigatorState.finalizeRoute, which will in turn call dispose on the route. This sequence lets the route perform an exit animation (or some other visual effect) after being popped but prior to being disposed.

Implementation

@override
bool didPop(T result) {
  if (_localHistory != null && _localHistory.isNotEmpty) {
    final LocalHistoryEntry entry = _localHistory.removeLast();
    assert(entry._owner == this);
    entry._owner = null;
    entry._notifyRemoved();
    if (_localHistory.isEmpty)
      changedInternalState();
    return false;
  }
  return super.didPop(result);
}