otp_forge library
Production-ready OTP authentication for Flutter.
Features SMS Retriever integration, OTP autofill, validation, resend timers, verification states, and fully customizable UI components.
Classes
- OtpAuthFlow
- Production-ready OTP verification widget with SMS autofill, validation, resend timer, and backend integration.
- OtpAutofillConfig
- Platform-aware configuration for OTP autofill fields.
- OtpAutoFillService
- Convenience wrapper that emits parsed OTP codes from SmsRetrieverService.
- OtpController
- Headless controller for OTP verification logic without UI.
- OtpInput
- OTP input widget supporting box, underline, and custom field styles.
- OtpParser
- Utility for extracting OTP codes from SMS messages and other text.
- OtpTheme
- Customizable visual theme for OTP input fields.
- SmsRetrieverService
- Listens for incoming SMS messages via the Android SMS Retriever API.
Enums
- OtpFieldStyle
- Visual style for individual OTP input fields.
- OtpState
- Represents the current state of the OTP verification flow.
Typedefs
- OnErrorCallback = void Function(String message)
- Callback invoked when verification or validation fails.
-
OnResendCallback
= Future<
void> Function() - Callback invoked when the user requests a resend.
- OnSuccessCallback = void Function(String message)
- Callback invoked after successful OTP verification.
- OtpFieldBuilder = Widget Function(BuildContext context, int index, String? digit, bool isFocused, bool hasError)
-
Builds a custom OTP field at
indexwith the currentdigit. - OtpValidator = String? Function(String otp)
-
Validates an OTP string. Return an error message or
nullif valid. -
VerifyOtpCallback
= Future<
bool> Function(String otp) -
Callback that verifies an OTP against a backend. Return
trueon success.