map<TR> method Null safety

TR map<TR>(
  1. {required ResultMapper<TR> pending,
  2. ValueResultMapper<T, TR>? initialValue,
  3. required ResultMapper<TR> waiting,
  4. required ValueResultMapper<T, TR> succeeded,
  5. required FailedResultMapper<TR> failed}
)

Pattern match the result on all branches

pending is called with action hasn't started initialValue is called when the action isn't started but initialValue is given waiting is called when action is in progress succeeded is called if result is succeeded failed is called with error and stackTrace if result is failed

Implementation

TR map<TR>({
  required ResultMapper<TR> pending,
  ValueResultMapper<T, TR>? initialValue,
  required ResultMapper<TR> waiting,
  required ValueResultMapper<T, TR> succeeded,
  required FailedResultMapper<TR> failed,
}) =>
    unsafeMapOr(
      pendingResult: pending,
      initialValueResult: initialValue,
      waitingResult: waiting,
      succeededResult: succeeded,
      failedResult: failed,
    );