forceList function
- dynamic item
Ensure the given item
is a List.
If item
is null
, an empty list is returned.
If item
is already a Iterable, a copy of items is returned in list.
Otherwise, item
is wrapped in a list and returned.
Implementation
List<dynamic> forceList(dynamic item) {
return [
if (item != null)
if (item is Iterable) ...item else item
];
}