Skip to content

Commit 355ba2a

Browse files
Alex BabichAlex Babich
authored andcommitted
- Fixed error in takeIf condition
1 parent 1db0162 commit 355ba2a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/src/common/functional_extender.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@ extension FunctionalExtender<T> on T? {
2525
T? takeIf(bool Function(T) f) {
2626
final T? self = this;
2727

28-
return self != null && f(self) ? self : null;
28+
if (self == null) return null;
29+
30+
if (f(self)) {
31+
return self;
32+
} else {
33+
return null;
34+
}
2935
}
3036
}
3137

0 commit comments

Comments
 (0)