maybeMap<R extends Object?> method

R maybeMap<R extends Object?>({
  1. R showLoading(
    1. EditFormUIStateShowLoading showLoading
    )?,
  2. R showContent(
    1. EditFormUIStateShowContent showContent
    )?,
  3. required R orElse(
    1. EditFormUIState editFormUIState
    ),
})

Implementation

R maybeMap<R extends Object?>({
  R Function(EditFormUIStateShowLoading showLoading)? showLoading,
  R Function(EditFormUIStateShowContent showContent)? showContent,
  required R Function(EditFormUIState editFormUIState) orElse,
}) {
  final editFormUIState = this;
  if (editFormUIState is EditFormUIStateShowLoading) {
    return showLoading != null
        ? showLoading(editFormUIState)
        : orElse(editFormUIState);
  } else if (editFormUIState is EditFormUIStateShowContent) {
    return showContent != null
        ? showContent(editFormUIState)
        : orElse(editFormUIState);
  } else {
    throw AssertionError();
  }
}