summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoruvok2025-07-30 13:18:45 +0200
committeruvok2025-07-30 13:18:45 +0200
commita5696a551577293f7afd4986119dd2d6636b1fdf (patch)
tree51504612afe0f09efc04d63d1e0e283d4cc96f4c
parent4311e39e65de3ed10f145e556085e7fb238e6e60 (diff)
firstWhereOrNull works on any iterable
-rw-r--r--lib/first_where_ext.dart3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/first_where_ext.dart b/lib/first_where_ext.dart
index 7e297ff..a633b91 100644
--- a/lib/first_where_ext.dart
+++ b/lib/first_where_ext.dart
@@ -1,5 +1,6 @@
-extension FirstWhereExt<T> on List<T> {
+extension FirstWhereExt<T> on Iterable<T> {
/// The first element satisfying [test], or `null` if there are none.
+ // firstWhereOrElse doesn't want to return null.
T? firstWhereOrNull(bool Function(T element) test) {
for (final element in this) {
if (test(element)) return element;