flutter_otp_widget 1.2.0
flutter_otp_widget: ^1.2.0 copied to clipboard
A highly customizable OTP (One-Time Password) text field widget for Flutter with support for multiple styles, themes, and input types.
Changelog #
1.2.0 #
Features #
- Every field now sends
AutofillHints.oneTimeCodeto the platform by default, so the keyboard can offer a one-time code it received, such as one from an SMS. A newautofillHintsparameter replaces the hints on every field;nullsends no autofill information, which on Android and web also turns autofill off. An autofilled code is handled as a paste.
Behaviour changes #
- Fields that set no
autofillHintsnow sendoneTimeCodeinstead of no hints, so the platform may offer codes where it offered nothing before. PassautofillHints: nullto keep them out of autofill. - On web, a field with
obscureTextand the default hint is now a DOMtextinput instead ofpassword, a result of Flutter's web autofill handling. PassautofillHints: nullto keep it a password input. - A field without focus now refuses a paste. This keeps a code that an
AutofillGroupfills into every field from being reported twice.
1.1.0 #
Features #
- Pasting a whole code into any field fills every field from the first, then calls
onChangeandonCompletedonce each with the full code. Only the charactersinputTypeallows are kept, so a code copied with spaces, hyphens or surrounding text pastes as the code.
Fixes #
- A focus requested inside
onCompleted, such as moving back to the first field after clearing a wrong code, now holds. When the code is completed in the last field or by a paste, that field's unfocus is now requested afteronChangeand beforeonCompleted, instead of after both.
Behaviour changes #
- A paste that leaves a number of allowed characters other than the field count now changes nothing. Before, a paste into an empty field kept its first allowed character.
1.0.3 #
Fixes #
- Fixed text vertical alignment in OTP fields by changing default
contentPaddingtoEdgeInsets.zero - Added
contentPaddingproperty toOTPThemefor customizable text field padding
1.0.2 #
1.0.1 #
Improvements #
- Enhanced example app with manual clear functionality and better focus management
1.0.0 #
Initial Release #
Features
- Multiple Field Styles: Box, underline, and circle styles
- Flexible Input Types: Support for numbers, text, and alphanumeric input
- Theming System: Light, dark, and fully customizable themes
- State Management: Error states, disabled states, and focus management
- Secure Input: Password/PIN mode with obscured text
- Keyboard Navigation: Arrow keys and backspace navigation between fields
- Auto Focus: Optional automatic focus on first field
- Customizable Layout: Adjustable field sizes, spacing, and center gaps
- Text Formatting: Text capitalization options
- Cursor Customization: Control cursor appearance (color, size, visibility)
- Callbacks:
onChangeandonCompletedevent handlers
Components
OTPTextField: Main widget for OTP inputOTPTheme: Theme configuration classOTPFieldStyle: Enum for field visual stylesOTPInputType: Enum for input type control
