unregister method

void unregister(
  1. ModalRoute route, {
  2. BuildContext? registrant,
})

Removes route (or a specific registrant on route) from the registry.

Implementation

void unregister(
  ModalRoute<dynamic> route, {
  BuildContext? registrant,
}) {
  final entries = _registry[route];
  if (entries == null) return;
  if (registrant != null) {
    _onstageRegistrants.remove(registrant);
    entries.removeWhere((entry) => identical(entry.registrant, registrant));
    if (entries.isNotEmpty) {
      _scheduleNotify();
      return;
    }
  }
  _registry.remove(route);
  if (identical(_sheetHold?.route, route)) _dropSheetHold();
  _unlisten(route.animation);
  _unlisten(route.secondaryAnimation);
  final listener = _clockListeners.remove(route);
  if (listener != null) route.animation?.removeStatusListener(listener);
  if (identical(_clockRoute, route)) _clockRoute = null;
  _scheduleNotify();
}