nextLayerName function
String
nextLayerName(
- CommandTarget target, [
- 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;
}
}