firstBy method
Find object on type T that matches criteria.
Implementation
T? firstBy(bool Function(T t) predicate) {
T? maybeValue;
forEach((entry) {
if (predicate.call(entry)) {
// Don't override the first found value.
maybeValue = maybeValue ?? entry;
}
});
return maybeValue;
}