fromStringList<T> static method
List<T>
fromStringList<
T>( - List<T> enumValues,
- List values
)
Implementation
static List<T> fromStringList<T>(List<T> enumValues, List<dynamic> values) {
/// Returns a list of enum items from a list of [String] values.
/// It receives a [List] of enum values and a [List] of [String] values as parameters.
/// It returns a [List] of enum items.
/// If the [values] is null, it returns an empty list.
if (values.isEmpty) return [];
List<T> listItems = [];
for (var enumItem in enumValues) {
String? result = values.cast<String>().firstWhereOrNull(
(value) => value.normalized() == EnumHelper.parse(enumItem)!.normalized(),
);
if (result != null) {
listItems.add(enumItem);
}
}
return listItems;
}