bind<R> method
- @useResult
- R? function(
- T value
Returns R?
produced by function
if this is not null. Otherwise returns null
.
This function is similar to map except that it returns R?
instead of R
.
String? foo = 'value';
foo.bind((v) => 'other value'); // 'other value';
foo.bind((v) => null); // null;
String? bar = null;
bar.bind((v) => 'other value'); // null
Implementation
@useResult R? bind<R>(R? Function(T value) function) => this == null ? null : function(this!);