toNullableArray static method
Converts value into array object. Single values are converted into arrays with a single element.
value
the value to convert. Returns array object or null when value is null.
Implementation
static List? toNullableArray(value) {
// Return null when nothing found
if (value == null) return null;
// Convert list
if (value is List) {
return value;
} else if (value is Map) {
var result = [];
for (var item in value.values) {
result.add(item);
}
return result;
} else if (value is Iterable) {
var result = [];
for (var item in value) {
result.add(item);
}
return result;
}
// Convert single values
else {
return [value];
}
}