otp_autofill_field 1.2.0 copy "otp_autofill_field: ^1.2.0" to clipboard
otp_autofill_field: ^1.2.0 copied to clipboard

Self-contained Flutter OTP field: PIN UI with automatic Android SMS Retriever and iOS one-time-code keyboard autofill, plus a resend timer. No external OTP/PIN dependency.

Changelog #

1.2.0 #

  • Fix broken consumer builds + full platform support. pluginClass: none is not a valid Flutter "no native code" marker — Flutter treats it as a class name and generates [none registerWithRegistrar:], failing iOS/desktop builds with "No podspec found" / "Module not found".
  • Every non-Android platform now ships a real but empty no-op plugin, so all 6 platforms are declared and build correctly:
    • iOS / macOS — empty Swift OtpAutofillFieldPlugin + podspec.
    • Windows / Linux — empty C/C++ registrant + CMake.
    • Web — OtpAutofillFieldWeb registration stub.
  • Swift Package Manager support for iOS and macOS — ships a Package.swift alongside the CocoaPods podspec, so the plugin integrates via SwiftPM (the default in Flutter 3.44+) and CocoaPods. CocoaPods apps ignore the manifest, so both paths coexist; the minimum Flutter version is unchanged.
  • Only Android has real native code (SMS Retriever). OTP autofill elsewhere is pure Flutter (AutofillHints.oneTimeCode); behavior unchanged.

1.1.2 #

  • iOS no longer ships a (no-op) native plugin — ios: pluginClass: none. OTP autofill on iOS is pure Flutter (AutofillHints.oneTimeCode), so no podspec/Swift code is needed. This removes the Swift Package Manager partial-score note; behavior is unchanged.

1.1.1 #

  • Fix: package now correctly declares support for all 6 platforms — Android, iOS, web, macOS, Windows, Linux (previously only Android/iOS, which under-reported real support). Only Android has native code (SMS Retriever); everywhere else the field is pure Flutter with no native dependency.

1.1.0 #

  • OtpResendTimer + OtpResendController — resend cooldown (default 1 min), theme-adaptive, customizable via builder / resendBuilder.
  • Full field customization: cellBuilder (OtpCellState), separatorBuilder, cursor options, digit entry animation (OtpCellAnimation) and haptic feedback (OtpHaptic).
  • Graceful degradation: every native call is guarded, so the field stays fully usable (manual entry, paste, completion, resend, error) when the SMS Retriever is unavailable — web, desktop, missing Play Services, etc.
  • Cells never overflow (wrapped in FittedBox.scaleDown).
  • Completion is detected centrally so onCompleted fires for typed and auto-filled codes; onAutoFill fires before onCompleted.
  • Re-arms automatically on clear so a resent OTP autofills.
  • Verified flutter build web succeeds; example gains web support.

1.0.0 #

Initial release — a self-contained OTP plugin (no third-party PIN or SMS dependencies).

  • AutoOtpField — OTP field combining own PIN cells + own Android SMS Retriever bridge + iOS oneTimeCode keyboard autofill.
  • OtpPinField — single-hidden-input PIN widget: correct per-cell paste, soft-keyboard backspace and full-code autofill.
  • OtpRetriever — own Android SMS Retriever bridge (native Kotlin plugin): leak-free, idempotent and timeout-aware (receiver always unregistered, no duplicate receivers).
  • AutoOtpControllercode, setCode (length-clamped), clearCode, triggerError, clearError, requestFocus, hasError. Fully owned — no surprise auto-dispose, no double-dispose.
  • AutoOtpTheme / AutoOtpShape — null-safe styling resolved from ThemeData.
  • AutoOtp.getAppSignature() / requestPhoneHint() static helpers.
  • OtpResendTimer + OtpResendController — resend cooldown (default 1 minute), theme-adaptive, fully customizable via builder / resendBuilder; auto-restarts after a successful resend.
  • Full field customization: cellBuilder (draw each cell yourself, OtpCellState), separatorBuilder (between cells), cursor options (showCursor/cursorColor/cursorWidth/cursorHeight), digit entry animation (cellAnimation: none/scale/fade/slide + duration/curve), and haptic feedback (none/light/medium/heavy/selection).

Robustness:

  • Cells never overflow — wrapped in FittedBox(scaleDown), so a narrow screen, long code, big cells or wide separators shrink to fit instead of throwing a RenderFlex overflowed error.

Refill / re-verify correctness:

  • SMS Retriever treated as one-shot (it is): torn down on delivery so a later attempt can re-arm.
  • reArmOnClear (default true) re-arms automatically when the field is cleared — a resent OTP autofills and onCompleted fires again.
  • Completion is driven explicitly from the autofill path, so a repeated / unchanged code can no longer be swallowed and onCompleted (your verify) always runs after autofill.
  • OtpRetriever.restart() for manual re-arm.
  • Completion is detected centrally from AutoOtpController (notifies on every change — typed, OS keyboard autofill, or SMS), so onCompleted can't be missed by a child widget's private listener.
  • onAutoFill fires before onCompleted (informational first); the SMS path also guarantees onCompleted even if the field already held the code.

Behavioral guarantees:

  • SMS listener and native receiver are always torn down.
  • start() is idempotent — no duplicate native receivers.
  • SMS Retriever timeout (~5 min) surfaced via onTimeout.
  • Retriever armed only on Android; iOS uses keyboard autofill.
  • Caller-supplied controller is never double-disposed.
  • onCompleted fires exactly once per code.
0
likes
160
points
293
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Self-contained Flutter OTP field: PIN UI with automatic Android SMS Retriever and iOS one-time-code keyboard autofill, plus a resend timer. No external OTP/PIN dependency.

Repository (GitHub)
View/report issues

Topics

#otp #sms #autofill #pin #authentication

License

MIT (license)

Dependencies

flutter, flutter_web_plugins

More

Packages that depend on otp_autofill_field

Packages that implement otp_autofill_field