diff options
author | uvok | 2025-07-30 13:14:38 +0200 |
---|---|---|
committer | uvok | 2025-07-30 13:14:38 +0200 |
commit | 4311e39e65de3ed10f145e556085e7fb238e6e60 (patch) | |
tree | 1073ff3a3cdd561087bc4d5b7620e49183741a1f /lib/first_where_ext.dart | |
parent | 9536bfa04db171aee987f042dccc4c2f16fa0f29 (diff) |
Add implementations of BLE controller
q&d
Diffstat (limited to 'lib/first_where_ext.dart')
-rw-r--r-- | lib/first_where_ext.dart | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/first_where_ext.dart b/lib/first_where_ext.dart new file mode 100644 index 0000000..7e297ff --- /dev/null +++ b/lib/first_where_ext.dart @@ -0,0 +1,9 @@ +extension FirstWhereExt<T> on List<T> { + /// The first element satisfying [test], or `null` if there are none. + T? firstWhereOrNull(bool Function(T element) test) { + for (final element in this) { + if (test(element)) return element; + } + return null; + } +} |