toButtonState method

HubbleButtonState toButtonState({
  1. HubbleButtonState? defaultValue,
  2. HubbleButtonState? successValue,
  3. HubbleButtonState? errorValue,
})

Implementation

HubbleButtonState toButtonState({
  HubbleButtonState? defaultValue,
  HubbleButtonState? successValue,
  HubbleButtonState? errorValue,
}) {
  if (isInProgress) {
    return HubbleButtonState.progress;
  } else if (isFailed) {
    return errorValue ?? HubbleButtonState.caution;
  } else if (isSuccess) {
    return successValue ?? HubbleButtonState.success;
  } else {
    return defaultValue ?? HubbleButtonState.enabled;
  }
}