list method
The list at path: the indexed entries in order, else one
comma-separated value split; empty items are dropped, and null when
there is neither.
Implementation
List<String>? list(String path) {
final indexed = <int, String>{};
for (final MapEntry(:key, :value) in values.entries) {
if (key.startsWith('$path.')) {
final index = int.tryParse(key.substring(path.length + 1));
if (index != null) {
indexed[index] = value.trim();
}
}
}
if (indexed.isNotEmpty) {
return [
for (final index in indexed.keys.toList()..sort())
if (indexed[index]!.isNotEmpty) indexed[index]!,
];
}
final value = this[path];
return value == null
? null
: [
for (final part in value.split(','))
if (part.trim().isNotEmpty) part.trim(),
];
}