madari-oss/lib/utils/common.dart
omkar f129eb7360
Some checks are pending
Build and Deploy / build_windows (push) Waiting to run
Build and Deploy / build_android (push) Waiting to run
Build and Deploy / build_android_tv (push) Waiting to run
Build and Deploy / build_ipa (push) Waiting to run
Build and Deploy / build_linux (push) Waiting to run
Build and Deploy / build_macos (push) Waiting to run
fix: trakt issues
2025-01-14 12:28:17 +05:30

23 lines
480 B
Dart

extension FirstWhereOrNullExtension<T> on Iterable<T> {
T? firstWhereOrNull(bool Function(T) test) {
for (var element in this) {
if (test(element)) {
return element;
}
}
return null;
}
}
extension LastWhereOrNullExtension<T> on Iterable<T> {
T? lastWhereOrNull(bool Function(T) test) {
T? elementItem;
for (var element in this) {
if (test(element)) {
elementItem = element;
}
}
return elementItem;
}
}