otp_autofill_field 1.2.0
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: noneis 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 —
OtpAutofillFieldWebregistration stub.
- iOS / macOS — empty Swift
- Swift Package Manager support for iOS and macOS — ships a
Package.swiftalongside 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 viabuilder/resendBuilder.- Full field customization:
cellBuilder(OtpCellState),separatorBuilder, cursor options, digit entry animation (OtpCellAnimation) andhapticfeedback (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
onCompletedfires for typed and auto-filled codes;onAutoFillfires beforeonCompleted. - Re-arms automatically on clear so a resent OTP autofills.
- Verified
flutter build websucceeds; 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 + iOSoneTimeCodekeyboard 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).AutoOtpController—code,setCode(length-clamped),clearCode,triggerError,clearError,requestFocus,hasError. Fully owned — no surprise auto-dispose, no double-dispose.AutoOtpTheme/AutoOtpShape— null-safe styling resolved fromThemeData.AutoOtp.getAppSignature()/requestPhoneHint()static helpers.OtpResendTimer+OtpResendController— resend cooldown (default 1 minute), theme-adaptive, fully customizable viabuilder/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), andhapticfeedback (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 aRenderFlex overflowederror.
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 andonCompletedfires 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), soonCompletedcan't be missed by a child widget's private listener. onAutoFillfires beforeonCompleted(informational first); the SMS path also guaranteesonCompletedeven 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.
onCompletedfires exactly once per code.