copyWith method

AFRouteState copyWith({
  1. AFRouteStateSegments? screenSegs,
  2. AFRouteStateSegments? popupSegs,
  3. Map<AFID, AFRouteSegment>? globalPool,
  4. AFTimeState? timeLastUpdate,
  5. Map<AFUIType, AFRouteStateShowScreen>? showScreen,
})

Implementation

AFRouteState copyWith({
  AFRouteStateSegments? screenSegs,
  AFRouteStateSegments? popupSegs,
  Map<AFID, AFRouteSegment>? globalPool,
  AFTimeState? timeLastUpdate,
  Map<AFUIType,  AFRouteStateShowScreen>? showScreen,
}) {
  var gp = globalPool ?? this.globalPool;
  if(!gp.containsKey(AFUIScreenID.unused)) {
    gp = Map<AFID, AFRouteSegment>.from(gp);
    gp[AFUIScreenID.unused] = const AFRouteSegment(param: AFRouteParamUnused.unused, children: null, createDefaultChildParam: null);
  }

  final revised = AFRouteState(
    screenHierarchy: screenSegs ?? this.screenHierarchy,
    globalPool: gp,
    timeLastUpdate: timeLastUpdate ?? this.timeLastUpdate,
    showingScreens: showScreen ?? this.showingScreens,
  );

  if(screenSegs != null) {
    AFibD.logRouteAF?.d("Revised Route $revised");
  }
  return revised;
}