onSubmitCreateDiseaseObservation method Null safety

dynamic onSubmitCreateDiseaseObservation(
  1. {required InputModeType inputMode,
  2. Function? callback}
)

Implementation

onSubmitCreateDiseaseObservation({required InputModeType inputMode, Function? callback}) async {
  LogManager().addLog("$buttonTitle 누름", action: LogConstants.buttonTap, screen: runtimeType.toString());
  if (!diseaseObservation.isValidate()) {
    EventService().eventBus.fire(
          PopupEvent(
            type: PopupType.alert,
            action: PopupAction.show,
            data: {"title": StringConstants.popupDiseaseObservationInvalidTitle, "content": StringConstants.popupDiseaseObservationInvalidContent},
            onClose: () {
              Navigator.of(context, rootNavigator: true).popUntil((route) => route.settings.name == DiseaseObservationCreateScreen.routeName);
            },
          ),
        );
    return;
  }

  String tempString = temperatureController.text.trim();
  diseaseObservation.temperature = tempString == "" ? 0 : double.parse(tempString);
  diseaseObservation.memo = memoController.text.trim();

  if (inputMode == InputModeType.create) {
    await ApiService().createDiseaseObservations(diseaseObservation: diseaseObservation);
    EventService().eventBus.fire(
          PopupEvent(
            type: PopupType.alert,
            action: PopupAction.show,
            data: {"title": StringConstants.popupDiseaseObservationCreateSuccessTitle, "content": StringConstants.popupDiseaseObservationCreateSuccessContent},
            onClose: () {
              Navigator.of(context, rootNavigator: true).popUntil((route) => route.settings.name == MainScreen.routeName);
            },
          ),
        );
  } else {
    await ApiService().updateDiseaseObservations(diseaseObservation: diseaseObservation);
    EventService().eventBus.fire(
      PopupEvent(
            type: PopupType.alert,
            action: PopupAction.show,
            data: {"title": StringConstants.popupDiseaseObservationUpdateSuccessTitle, "content": StringConstants.popupDiseaseObservationUpdateSuccessContent},
            onClose: () {
              Navigator.of(context, rootNavigator: true).popUntil((route) => route.settings.name == MainScreen.routeName);
            },
          ),
        );
  }

  callback?.call(diseaseObservation);
}