toList<T> static method
Converts a comma-separated string or list to a list of a specified type.
Example: '1,2,3' -> 1, 2, 3
Implementation
static List<T> toList<T>({
List<dynamic>? list,
String? value,
String regex = ",",
}) {
if (list != null && list.isNotEmpty && list.first is T) {
return list.cast<T>();
} else if (value != null) {
return value.split(regex).cast<T>();
} else {
return [];
}
}