when<R extends Object?> method

R when<R extends Object?>({
  1. required R showLoading(),
  2. required R showContent(
    1. List<FormViewModel> viewModels,
    2. bool showNonEditableFields
    ),
})

Implementation

R when<R extends Object?>({
  required R Function() showLoading,
  required R Function(
          List<FormViewModel> viewModels, bool showNonEditableFields)
      showContent,
}) {
  final editFormUIState = this;
  if (editFormUIState is EditFormUIStateShowLoading) {
    return showLoading();
  } else if (editFormUIState is EditFormUIStateShowContent) {
    return showContent(
        editFormUIState.viewModels, editFormUIState.showNonEditableFields);
  } else {
    throw AssertionError();
  }
}