Flutter UI Walkthrough — OTP Verify

By Engineering Team•October 10, 2026•3 min read

What the shopper sees

A 6-box OTP input, a countdown showing when a new code can be requested, a “Resend Code” action (disabled until the countdown ends), and a “Verify” button. The same screen is used right after signup and right after login — nothing visually distinguishes which mode it’s in.

What the shopper does here

  • Enters the 6-digit code received for their phone number.
  • Waits out a 30-second cooldown, or taps “Resend Code” once it’s enabled, up to 3 times total.
  • Taps “Verify” to complete sign-in.

How it’s built

OtpVerifyController.onInit() reads phone, mode, and (signup only) termsAccepted/termsVersion/privacyVersion off Get.arguments — these were handed over by whichever screen navigated here. A private _isSignup getter (mode == 'signup') is the single switch every subsequent action branches on; there’s no separate controller or view per mode.

A Timer.periodic ticks remainingSeconds down from _resendSeconds = 30 each second, flips canResend to true at zero, and is cancelled in onClose() along with disposing the scroll controller. onResend() first checks _resendAttempts >= _maxResendAttempts (_maxResendAttempts = 3) and shows a “Maximum Attempts” snackbar if so, without calling the repository at all; otherwise it calls sendSignupOtp/sendLoginOtp based on _isSignup, increments _resendAttempts, and restarts the timer.

The visible OTP boxes are the shared OtpInputField widget (core/widgets/fields/app_otp_input_field.dart) — a hidden TextField backs the bordered-box display and supports autofill via AutofillHints.oneTimeCode, so a code delivered by SMS can fill in without manual entry on supporting devices.

onVerify() guards on otpCode.value.length < 6 || isVerifying.value, then calls verifySignupOtp(phone, otpCode, termsAccepted, termsVersion, privacyVersion) or verifyLoginOtp(phone, otpCode) depending on _isSignup. Both repository methods funnel a successful response through the same shared _completeSignIn — extract custom_token from the response, signInWithCustomToken, then saveUserSession. A thrown AppException is caught and shown as a “Verification failed” snackbar; on success the controller calls Get.offAllNamed(AppRoutes.mainLayout), clearing the entire pre-auth navigation stack.

OTP verify screen, identical for both signup and login