where method
Returns this if it is not null and satisfies predicate
. Otherwise returns null
.
String? foo = 'value';
foo.where((v) => v == 'value'); // 'value'
foo.where((v) => v == 'other'); // null
String? bar = null;
bar.where((e) => e == 'value'); // null
Implementation
@useResult T? where(Predicate<T> predicate) => this != null && predicate(this!) ? this : null;