pin_code_fields 9.0.0-dev.2
pin_code_fields: ^9.0.0-dev.2 copied to clipboard
A highly customizable PIN/OTP input field for Flutter with Material Design support and headless core for custom UIs.
Changelog #
9.0.0-dev.2 Feature Enhancements #
Features ✨ #
- Accessibility (Semantics): Full screen reader support with
semanticLabelparameter- Announces field purpose (e.g., "6-digit PIN code field")
- Provides hints about remaining digits
- Masks values when obscured for privacy
- Exposes enabled/focused states
cursorAlignment: Position custom cursor widgets within cells (e.g., underscore at bottom)MaterialPinTheme( cursorAlignment: Alignment.bottomCenter, cursorWidget: myUnderscoreCursor, )onClipboardFound: Callback when clipboard contains valid PIN-like content on focusonTapOutside: Callback when user taps outside the fielderrorText&errorBuilder: Custom error display below the PIN fieldfollowingFillColor&followingBorderColor: Style for cells after the focused cellcompleteFillColor,completeBorderColor&completeTextStyle: Style when all cells are filled
Bug Fixes 🐛 #
- Focus on complete: Last cell now shows focused state when PIN is complete and field is focused
- Cursor alignment: Fixed custom cursor positioning - removed internal
Centerwidget that was overriding alignment - Web input: Fixed text input not working on web by adjusting invisible text field configuration
- Controller notifications: Fixed
PinInputControllernot notifying listeners on focus/text changes
Example App 📱 #
- Added comprehensive use case demos (OTP verification, PIN setup, PIN login, payment confirmation, invite codes, app lock screen)
- Added feature demos for all customization options:
- Quick Start: Basic usage, Controller demo
- Shapes & Themes: Shape gallery, Color customization, Shadows & elevation
- Animations: Entry animations, Custom cursor
- State Theming: All states demo, Error handling
- Customization: Headless builder, Hints, Obscure text, Separators, Text gradient
- Interactions: Clipboard detection, Form validation, Autofill & SMS
- Added interactive Playground for real-time customization of all options
9.0.0 Major Architecture Refactor #
Breaking Changes ⚠️ #
This is a complete rewrite with a new headless architecture. Migration required.
- New Headless Architecture: The package now provides both a headless core (
PinInput) and a Material Design implementation (MaterialPinField) - Unified Controller:
PinInputControllerreplaces separateTextEditingController,FocusNode, anderrorAnimationController - Theme System: New
MaterialPinThemewith automaticColorSchemeresolution - Renamed Parameters: See migration guide below
Features ✨ #
- Headless Core: Build completely custom PIN UIs with
PinInputandPinCellData - Material Design Ready: Use
MaterialPinFieldfor beautiful, ready-to-use PIN fields - PinInputController: Single controller for text, focus, and error state management
setText(),clear(),text- Text controltriggerError(),clearError(),hasError- Error controlrequestFocus(),unfocus(),hasFocus- Focus control
- Improved Animations: Scale, fade, slide, and none animation types
- All Cell Shapes: Outlined, filled, underlined, and circle
- Text Gradient: Apply gradients to PIN text via
MaterialPinTheme.textGradient - Custom Obscuring Widget: Use any widget for obscuring with
obscuringWidget - Form Integration:
PinInputFormFieldfor form validation - SMS Autofill: Full autofill support with
enableAutofillandautofillHints - Haptic Feedback: Configurable haptic feedback types
Migration Guide #
Parameter Renames
| Old Name | New Name |
|---|---|
controller |
pinController.textController |
focusNode |
pinController.focusNode |
useHapticFeedback |
enableHapticFeedback |
hapticFeedbackTypes |
hapticFeedbackType |
animationType |
theme.entryAnimation |
enableContextMenu |
enablePaste |
errorAnimationController |
pinController.triggerError() |
pinTheme |
theme (MaterialPinTheme) |
enablePinAutofill |
enableAutofill |
Basic Migration
Before (v8.x):
PinCodeTextField(
appContext: context,
length: 6,
controller: textController,
focusNode: focusNode,
pinTheme: PinTheme(
shape: PinCodeFieldShape.box,
activeColor: Colors.blue,
),
onChanged: (value) {},
onCompleted: (value) {},
)
After (v9.0):
final pinController = PinInputController();
MaterialPinField(
length: 6,
pinController: pinController,
theme: MaterialPinTheme(
shape: MaterialPinShape.outlined,
focusedBorderColor: Colors.blue,
),
onChanged: (value) {},
onCompleted: (value) {},
)
Error Handling Migration
Before:
final errorController = StreamController<ErrorAnimationType>();
errorController.add(ErrorAnimationType.shake);
After:
final pinController = PinInputController();
pinController.triggerError(); // Triggers shake + sets error state
pinController.clearError(); // Clears error state
8.0.1 #
- Added
activeBorderWidth,selectedBorderWidth,inactiveBorderWidth,disabledBorderWidth,errorBorderWidth
8.0.0 #
- Updated Dart SDK constraint
sdk: ">=2.12.0 <4.0.0" - Use
PinCodePlatforminsteadPlatformenum - Numerous bug fixes, thanks to each and every contributor for resolving issues
7.4.0 #
- Added new attributes
readOnly,textGradient,errorTextDirection,errorTextMargin,autoUnfocus - Resolved blinkDebounce
setState()afterdispose()bug - Example app refactor
7.3.0 #
- Fixed extra padding if autoValidate is not provided
- Added ScrollPadding, errorBorderColor
7.2.0 #
- Much requested feature placeholder has been added
hintCharacter hintStylehas been added to customize the hint TextStyle
7.1.0 #
- Added
useExternalAutoFillGroupto use this widget with externalAutofillGroup - Added
fieldOuterPaddingto add extra padding on each cells. Default to 0.0
7.0.0 #
- Added null-safety to the main branch
6.1.0 #
- Added haptic feedback
- Added animated obscure widget support
obscuringWidgetandblinkWhenObscuring
6.0.0 #
- Added Cursor support
- Added boxShadows
- Minimum Flutter version is set to 1.22.0
5.0.0 #
- Added iOS autofill with Flutter version 1.20.0
- Added onSave, onTap callbacks
- Added PastedTextStyle
4.0.0 #
- Added support for flutter-web
3.0.0 #
- Introduced
PinTheme&DialogConfig - Added
beforeTextPastecallback - Added
onCompletedcallback
2.0.0 #
- Added animations while changing value
- Added multiple customization parameters
- Pressing backspace focuses previous field