mapOr<TR> method Null safety

TR mapOr<TR>(
  1. {ResultMapper<TR>? pending,
  2. ValueResultMapper<T, TR>? initialValue,
  3. ResultMapper<TR>? waiting,
  4. ValueResultMapper<T, TR>? succeeded,
  5. FailedResultMapper<TR>? failed,
  6. ResultMapper<TR>? notStarted,
  7. ResultMapper<TR>? finished,
  8. ValueResultMapper<T, TR>? hasValue,
  9. required ResultMapper<TR> orElse}
)

Pattern match the result with else branch

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 completed failed is called with error and stackTrace if result is failed

notStarted is called on pending or initialValue. Not called if pending or initialValue is given. finished is either completed or failed. Not called if failed or succeeded is given. hasValue is called on initialValue or succeeded. Not called if initialValue or succeeded is given.

orElse is called if no specific state mapper is given

Implementation

TR mapOr<TR>({
  ResultMapper<TR>? pending,
  ValueResultMapper<T, TR>? initialValue,
  ResultMapper<TR>? waiting,
  ValueResultMapper<T, TR>? succeeded,
  FailedResultMapper<TR>? failed,
  ResultMapper<TR>? notStarted,
  ResultMapper<TR>? finished,
  ValueResultMapper<T, TR>? hasValue,
  required ResultMapper<TR> orElse,
}) =>
    unsafeMapOr(
      pendingResult: pending,
      waitingResult: waiting,
      initialValueResult: initialValue,
      succeededResult: succeeded,
      failedResult: failed,
      isNotStarted: notStarted,
      isFinished: finished,
      hasValue: hasValue,
      orElse: orElse,
    );