map<R extends Object> method

  1. @useResult
R? map<R extends Object>(
  1. R function(
    1. T value
    )
)

Returns R if this is not null. Otherwise returns null.

This function is similar to bind except that it returns R instead of R?

String? foo = 'value';
foo.map((v) => 'other value'); // 'other value'

String? bar = null;
bar.map((v) => 'other value'); // null

Implementation

@useResult R? map<R extends Object>(R Function(T value) function) => this == null ? null : function(this!);