discontinuedPackage jet_cad_floor_plan has been discontinued and replaced by jet_cad_2d_plan.

nextTableNumber function

String nextTableNumber(
  1. Iterable<String> numbers
)

The next table number over the live tables' numbers (T5): max + 1 over the counted ones, written without leading zeros; "1" when none counts. When max + 1 would take nine digits, the smallest unused positive integer instead, so a placement never makes a duplicate or an invalid number.

Implementation

String nextTableNumber(Iterable<String> numbers) {
  final used = <int>{};
  var max = 0;
  for (final n in numbers) {
    final v = countedTableNumber(n.trim());
    if (v == null) continue;
    used.add(v);
    if (v > max) max = v;
  }
  if (max < _kLargestCounted) return '${max + 1}';
  var candidate = 1;
  while (used.contains(candidate)) {
    candidate++;
  }
  return '$candidate';
}