onTapSignIn method Null safety

dynamic onTapSignIn(
  1. BuildContext context
)

Implementation

onTapSignIn(BuildContext context) async {
  LogManager().addLog("로그인 버튼 클릭", screen: runtimeType.toString());
  if (_isSubmitting) return;

  _isSubmitting = true;
  final username = usernameController.text.trim();
  final password = passController.text.trim();

  try {
    EventService().eventBus.fire(PopupEvent(type: PopupType.loading, action: PopupAction.show));
    await ApiService().signIn(username, password);
    // 로그인 성공
    LogManager().addLog("로그인 성공", screen: runtimeType.toString());
    splashScreenKey.currentState?.init();
    Navigator.of(context, rootNavigator: true).popUntil((route) => route.settings.name == SplashScreen.routeName);
    // Navigator.of(context, rootNavigator: true).pushReplacementNamed(FarmLoadingScreen.routeName);
    _isSubmitting = false;
    return;
  } on AuthException catch (e) {
    LogManager().addLog("로그인 실패 ${e.message}");

    if (e.message == "User is not confirmed.") {
      EventService().eventBus.fire(
            PopupEvent(
              type: PopupType.alert,
              action: PopupAction.show,
              data: {"title": "인증되지 않은 계정입니다.", "content": "인증을 다시 진행해 주세요."},
              onClose: () async {
                await Amplify.Auth.resendSignUpCode(username: username);
                Navigator.of(context, rootNavigator: true).popUntil((route) => route.settings.name == SplashScreen.routeName);
                Navigator.of(context, rootNavigator: true).pushNamed(PhoneAuthScreen.routeName, arguments: PhoneAuthScreenArguments(username: username));
              },
            ),
          );
    } else if (e.message == "User does not exist.") {
      EventService().eventBus.fire(
            PopupEvent(
              type: PopupType.alert,
              action: PopupAction.show,
              data: {"title": "등록되지 않은 계정", "content": "등록되지 않은 계정입니다."},
              onClose: () async {
                Navigator.of(context, rootNavigator: true).popUntil((route) => !route.settings.name!.startsWith(PopupScreen.routeName));
              },
            ),
          );
    } else {
      EventService().eventBus.fire(
            PopupEvent(
              type: PopupType.alert,
              action: PopupAction.show,
              data: {"title": "로그인 실패", "content": "아이디와 비밀번호를 다시 확인하세요."},
              onClose: () {
                Navigator.of(context, rootNavigator: true).popUntil((route) => !route.settings.name!.startsWith(PopupScreen.routeName));
              },
            ),
          );
    }
  } catch (e) {
    LogManager().addLog("로그인 실패: $e");

    EventService().eventBus.fire(
          PopupEvent(
            type: PopupType.alert,
            action: PopupAction.show,
            data: {"title": "로그인 실패", "content": e},
            onClose: () {
              Navigator.of(context, rootNavigator: true).popUntil((route) => !route.settings.name!.startsWith(PopupScreen.routeName));
            },
          ),
        );
  }
  _isSubmitting = false;
}