removeFromCache method

void removeFromCache(
  1. Iterable<RouteState<Object?>> routeStates
)

Implementation

void removeFromCache(Iterable<RouteState> routeStates) {
  var mutated = false;
  for (final routeState in routeStates) {
    final builder = _getBuilderByPath(routeState.uri);
    if (builder == null) continue;
    final stillReferenced = identical(routeState, currentRouteState) ||
        identical(routeState, _previousRouteForTransition);
    if (stillReferenced) {
      if (_widgetCache[routeState] is SizedBox) continue;
      _widgetCache[routeState] = SizedBox.shrink(key: routeState.key);
      mutated = true;
    } else {
      if (_widgetCache.remove(routeState) != null) mutated = true;
    }
  }
  if (mutated) _invalidateCachedViews();
}