otp_autofill_field 1.1.3
otp_autofill_field: ^1.1.3 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.1.3 #
- Fix broken consumer builds.
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".- iOS now ships a real but empty
OtpAutofillFieldPlugin(Swift no-op) + its podspec. iOS autofill remains pure Flutter (AutofillHints.oneTimeCode). - macOS / Windows / Linux plugin entries removed (they needed no native
code and
noneonly broke them). The pure-Flutter widget still works on those platforms — they just aren't declared as plugin platforms.
- iOS now ships a real but empty
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 #
Rebuilt as a self-contained plugin — no pin_code_fields or
sms_autofill dependency. Both are reimplemented.
AutoOtpField— OTP field combining own PIN cells + own Android SMS Retriever bridge + iOSoneTimeCodekeyboard autofill.OtpPinField— single-hidden-input PIN widget. Fixes the per-cell paste / soft-backspace / partial-autofill bugs ofpin_code_fields.OtpRetriever— own Android SMS Retriever bridge (native Kotlin plugin): leak-free, idempotent, timeout-aware. Fixes thesms_autofillreceiver / stream leak and duplicate-receiver bug.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.