otp_autofill_field library

otp_autofill_field

A self-contained OTP input. It does not depend on pin_code_fields or sms_autofill; both are reimplemented here, better:

  • One hidden input behind the cells, instead of one field per cell. The per-cell design is why older pin packages mishandle paste, soft backspace and autofill — this design gets all three right for free.
  • Own Android SMS Retriever bridge with a leak-free, idempotent, timeout-aware lifecycle (cancels the Dart stream and unregisters the native receiver; a double start() cannot register two receivers).
  • iOS one-time-code autofill via an AutofillGroup + the oneTimeCode hint, so iOS surfaces the SMS code on the keyboard automatically (Apple disallows reading SMS programmatically — this is the supported path).
  • Single completiononCompleted fires exactly once per code.
  • Owned controller — no surprise auto-dispose, no double-dispose.

Classes

AutoOtp
Static entry points that don't need a widget in the tree.
AutoOtpController
Controller for an AutoOtpField.
AutoOtpField
A fixed-length OTP input that fills itself from an incoming SMS.
AutoOtpTheme
Styling for an AutoOtpField.
OtpCellState
State of a single cell, passed to a custom cellBuilder.
OtpPinField
A dependency-free PIN/OTP cell widget.
OtpResendController
Drives an OTP resend cooldown.
OtpResendTimer
"Resend code in 0:59" → "Resend code", with a cooldown in between.
OtpRetriever
Own, dependency-free wrapper around the Android SMS Retriever API.
ResolvedAutoOtpTheme
AutoOtpTheme with all colors resolved against a concrete ThemeData.

Enums

AutoOtpShape
Cell shape for AutoOtpField (ignored when a custom cellBuilder is set).
OtpCellAnimation
How a digit appears in its cell.
OtpHaptic
Haptic feedback fired when a digit is entered / the code completes.

Typedefs

OtpCellBuilder = Widget Function(BuildContext context, OtpCellState state)
Builds one cell. Return any widget — you fully control its look.
OtpSeparatorBuilder = Widget Function(BuildContext context, int index)
Builds the separator shown before cell index (1.. length-1).