increment method

int increment(
  1. int max, {
  2. String route = "default",
})

Implementation

int increment(int max, {String route = "default"}) {
  int i = 0;
  log("CommonInterface:[increment]->MainObj->${screenAdIndex}}");
  if (screenAdIndex.containsKey(route)) {
    i = screenAdIndex[route]!;
    log("CommonInterface:[increment]->AlreadyVisited->$i}");
  } else {
    screenAdIndex[route] = 0;
    log("CommonInterface:[increment]->FirstTime->$i}");
  }

  if (i < max) {
    i = i + 1;
    screenAdIndex[route] = i;
    log("CommonInterface:[increment]->UnderFlow->$i}");
    return screenAdIndex[route]!;
  }
  log("CommonInterface:[increment]->OverFlow->$i}");
  screenAdIndex[route] = 0;
  return screenAdIndex[route] ?? 0;
}