PinInput class
Headless PIN input widget.
This widget captures keyboard input and manages PIN state but delegates ALL visual rendering to the provided builder. You decide exactly how each cell should look - this widget just provides the data.
Example:
PinInput(
length: 6,
builder: (context, cells) {
return Row(
children: cells.map((cell) => MyCustomCell(data: cell)).toList(),
);
},
onCompleted: (pin) => print('PIN: $pin'),
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- PinInput
Constructors
-
PinInput({Key? key, required int length, required PinCellBuilder builder, PinInputController? pinController, String? initialValue, TextInputType keyboardType = TextInputType.number, TextInputAction textInputAction = TextInputAction.done, List<
TextInputFormatter> ? inputFormatters, TextCapitalization textCapitalization = TextCapitalization.none, Iterable<String> ? autofillHints, bool enabled = true, bool autoFocus = false, bool readOnly = false, bool autoDismissKeyboard = true, bool clearErrorOnInput = true, bool obscureText = false, String obscuringCharacter = '●', bool blinkWhenObscuring = true, Duration blinkDuration = const Duration(milliseconds: 500), bool enableHapticFeedback = true, HapticFeedbackType hapticFeedbackType = HapticFeedbackType.light, bool enablePaste = true, TextSelectionControls? selectionControls, EditableTextContextMenuBuilder? contextMenuBuilder = defaultPinContextMenuBuilder, ValueChanged<String> ? onClipboardFound, bool clipboardValidator(String text, int length)?, ValueChanged<String> ? onChanged, ValueChanged<String> ? onCompleted, ValueChanged<String> ? onSubmitted, VoidCallback? onEditingComplete, VoidCallback? onTap, VoidCallback? onLongPress, void onTapOutside(PointerDownEvent event)?, MouseCursor? mouseCursor, Brightness? keyboardAppearance, EdgeInsets scrollPadding = const EdgeInsets.all(20), bool enableAutofill = false, AutofillContextAction autofillContextAction = AutofillContextAction.commit, String? semanticLabel}) -
const
Properties
- autoDismissKeyboard → bool
-
Whether to dismiss the keyboard when PIN is complete.
final
- autofillContextAction → AutofillContextAction
-
Action to perform when the autofill context is disposed.
final
-
autofillHints
→ Iterable<
String> ? -
Autofill hints for the text field.
final
- autoFocus → bool
-
Whether to auto-focus on mount.
final
- blinkDuration → Duration
-
Duration to show the character before obscuring.
final
- blinkWhenObscuring → bool
-
Whether to briefly show the character before obscuring.
final
- builder → PinCellBuilder
-
Builder that receives cell data and returns the visual representation.
final
- clearErrorOnInput → bool
-
Whether to automatically clear error state when user types.
final
- clipboardValidator → bool Function(String text, int length)?
-
Custom validator for clipboard content.
final
- contextMenuBuilder → EditableTextContextMenuBuilder?
-
Builder for the context menu (paste functionality).
final
- enableAutofill → bool
-
Whether to enable autofill (e.g., SMS OTP autofill).
final
- enabled → bool
-
Whether the field is enabled.
final
- enableHapticFeedback → bool
-
Whether to trigger haptic feedback on input.
final
- enablePaste → bool
-
Whether to enable paste functionality.
final
- hapticFeedbackType → HapticFeedbackType
-
Type of haptic feedback to trigger.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- initialValue → String?
-
Initial value for the PIN input.
final
-
inputFormatters
→ List<
TextInputFormatter> ? -
Additional input formatters to apply.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- keyboardAppearance → Brightness?
-
The brightness of the keyboard.
final
- keyboardType → TextInputType
-
The type of keyboard to display.
final
- length → int
-
Number of PIN cells.
final
- mouseCursor → MouseCursor?
-
The mouse cursor to show when hovering over the widget.
final
- obscureText → bool
-
Whether to obscure the entered text.
final
- obscuringCharacter → String
-
Character used to obscure text.
final
-
onChanged
→ ValueChanged<
String> ? -
Called when the text changes.
final
-
onClipboardFound
→ ValueChanged<
String> ? -
Called when the clipboard contains valid PIN-like content on focus.
final
-
onCompleted
→ ValueChanged<
String> ? -
Called when the PIN is complete (all cells filled).
final
- onEditingComplete → VoidCallback?
-
Called when editing is complete.
final
- onLongPress → VoidCallback?
-
Called when the widget is long pressed.
final
-
onSubmitted
→ ValueChanged<
String> ? -
Called when the user submits (keyboard action button).
final
- onTap → VoidCallback?
-
Called when the widget is tapped.
final
- onTapOutside → void Function(PointerDownEvent event)?
-
Called when user taps outside the field.
final
- pinController → PinInputController?
-
Controller for the PIN input.
final
- readOnly → bool
-
Whether the field is read-only.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrollPadding → EdgeInsets
-
Padding when scrolling the field into view.
final
- selectionControls → TextSelectionControls?
-
Custom text selection controls.
final
- semanticLabel → String?
-
Semantic label for accessibility.
final
- textCapitalization → TextCapitalization
-
How to capitalize text input.
final
- textInputAction → TextInputAction
-
The action button to display on the keyboard.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< PinInput> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited