firstWhereOrNull<T> static method
After Dart 2.12, firstWhere
can be a non-nullable return value. Instead of an extension,
a predictable static method is used instead.
From https://github.com/dart-lang/collection/blob/master/lib/src/iterable_extensions.dart to avoid importing a package for a single function.
Implementation
static T? firstWhereOrNull<T>(Iterable<T> values, bool Function(T item) test) {
for (var item in values) {
if (test(item)) return item;
}
return null;
}