discontinuedPackage jet_cad_floor_plan has been discontinued and replaced by jet_cad_2d_plan.

nextLayerName function

String nextLayerName(
  1. CommandTarget target, [
  2. FloorPlanStrings strings = const FloorPlanStringsEn()
])

The name the panel's + gives a new layer (spec 12b D4, spec 14d L7): strings' Layer N, the smallest N ≥ 1 that no layer's name already takes in any built-in language (by toLowerCase(), the table's own folding) and that layerNameError accepts in target.

Implementation

String nextLayerName(CommandTarget target,
    [FloorPlanStrings strings = const FloorPlanStringsEn()]) {
  final used = <int>{
    for (final r in target.tables.layers.records)
      if (numberedNameIndex(r.name, (s, n) => s.layerName(n), strings,
              fold: (s) => s.toLowerCase())
          case final n?)
        n,
  };
  for (var n = 1;; n++) {
    if (used.contains(n)) continue;
    final name = strings.layerName(n);
    if (layerNameError(target, name) == null) return name;
  }
}