removeLocalHistoryEntry method Null safety

void removeLocalHistoryEntry(
  1. LocalHistoryEntry entry
)

Remove a local history entry from this route.

The entry's LocalHistoryEntry.onRemove callback, if any, will be called synchronously.

Implementation

void removeLocalHistoryEntry(LocalHistoryEntry entry) {
  assert(entry != null);
  assert(entry._owner == this);
  assert(_localHistory!.contains(entry));
  _localHistory!.remove(entry);
  entry._owner = null;
  entry._notifyRemoved();
  if (_localHistory!.isEmpty) {
    if (SchedulerBinding.instance!.schedulerPhase == SchedulerPhase.persistentCallbacks) {
      // The local history might be removed as a result of disposing inactive
      // elements during finalizeTree. The state is locked at this moment, and
      // we can only notify state has changed in the next frame.
      SchedulerBinding.instance!.addPostFrameCallback((Duration duration) {
        changedInternalState();
      });
    } else {
      changedInternalState();
    }
  }
}