firstWhereOrDefault method
a firstWhere implementation that allows for a nullable return type when the lists elements are non-nullable
Implementation
T? firstWhereOrDefault(bool Function(T) test) {
final list = where((element) => test(element)).toList();
if (list.isNotEmpty) {
return list.first;
}
return null;
}