replaceAll method

AFRouteStateSegments replaceAll(
  1. AFRouteParam param,
  2. List<AFRouteParam>? children,
  3. AFCreateDefaultChildParamDelegate? createDefaultChildParam
)

Removes all existing segments in the route, and adds back the specified screen/data.

Implementation

AFRouteStateSegments replaceAll(AFRouteParam param, List<AFRouteParam>? children, AFCreateDefaultChildParamDelegate? createDefaultChildParam) {

  // this prevent us from removing afib test screens.
  final revised = List<AFRouteSegment>.of(active);
  final popCount = this.popCountToRoot;
  final priorLastSegment = _cyclePrior(revised, popCount);

  revised.add(AFRouteSegment.withParam(param, children, createDefaultChildParam));
  return copyWith(
    active: revised,
    prior: priorLastSegment
  );
}