generateHandle method

int generateHandle()

Implementation

int generateHandle() {
  int newHandle = 0;
  final Random rng = Random();
  newHandle = rng.nextInt(100);
  loop++;

  if (handles.isEmpty) {
    final Params hndle = Params(handle: newHandle);
    this.handles.add(hndle);
    return newHandle;
  } else if (this.handles.every((Params h) => h.handle != newHandle)) {
    final Params hndle = Params(handle: newHandle);
    this.handles.add(hndle);
    return newHandle;
  } else {
    if (loop < 10) {
      return generateHandle();
    } else {
      loop = 0;
      return 0;
    }
  }
}