PinCodeTextField class

Pin code text fields which automatically changes focus and validates

Inheritance

Constructors

PinCodeTextField({Key? key, required BuildContext appContext, required int length, TextEditingController? controller, bool obscureText = false, String obscuringCharacter = '●', Widget? obscuringWidget, bool blinkWhenObscuring = false, Duration blinkDuration = const Duration(milliseconds: 500), ValueChanged<String>? onChanged, ValueChanged<String>? onCompleted, Color? backgroundColor, MainAxisAlignment mainAxisAlignment = MainAxisAlignment.spaceBetween, Duration animationDuration = const Duration(milliseconds: 150), Curve animationCurve = Curves.easeInOut, AnimationType animationType = AnimationType.slide, TextInputType keyboardType = TextInputType.visiblePassword, bool autoFocus = false, FocusNode? focusNode, Function? onTap, bool enabled = true, List<TextInputFormatter> inputFormatters = const <TextInputFormatter>[], TextStyle? textStyle, bool useHapticFeedback = false, HapticFeedbackTypes hapticFeedbackTypes = HapticFeedbackTypes.light, TextStyle? pastedTextStyle, bool enableActiveFill = false, TextCapitalization textCapitalization = TextCapitalization.none, TextInputAction textInputAction = TextInputAction.done, bool autoDismissKeyboard = true, bool autoDisposeControllers = true, ValueChanged<String>? onSubmitted, VoidCallback? onEditingComplete, StreamController<ErrorAnimationType>? errorAnimationController, bool beforeTextPaste(String? text)?, DialogConfig? dialogConfig, PinTheme pinTheme = const PinTheme.defaults(), Brightness? keyboardAppearance, FormFieldValidator<String>? validator, FormFieldSetter<String>? onSaved, AutovalidateMode autovalidateMode = AutovalidateMode.onUserInteraction, double errorTextSpace = 16, TextDirection errorTextDirection = TextDirection.ltr, EdgeInsets errorTextMargin = EdgeInsets.zero, bool enablePinAutofill = true, int errorAnimationDuration = 500, List<BoxShadow>? boxShadows, bool showCursor = true, Color? cursorColor, double cursorWidth = 2, double? cursorHeight, String? hintCharacter, TextStyle? hintStyle, Gradient? textGradient, bool readOnly = false, bool autoUnfocus = true, AutofillContextAction onAutoFillDisposeAction = AutofillContextAction.commit, bool useExternalAutoFillGroup = false, EdgeInsets scrollPadding = const EdgeInsets.all(20), IndexedWidgetBuilder? separatorBuilder})

Properties

animationCurve Curve
Curve for the animation. Default is Curves.easeInOut
final
animationDuration Duration
Duration for the animation. Default is Duration(milliseconds: 150)
final
animationType AnimationType
AnimationType for the text to appear in the pin code field. Default is AnimationType.slide
final
appContext BuildContext
The BuildContext of the application
final
autoDismissKeyboard bool
Auto dismiss the keyboard upon inputting the value for the last field. Default is true
final
autoDisposeControllers bool
Auto dispose the controller and FocusNode upon the destruction of widget from the widget tree. Default is true
final
autoFocus bool
If the pin code field should be autofocused or not. Default is false
final
autoUnfocus bool
Enable auto unfocus
final
autovalidateMode AutovalidateMode
enables auto validation for the TextFormField Default is AutovalidateMode.onUserInteraction
final
backgroundColor Color?
background color for the whole row of pin code fields.
final
beforeTextPaste → (bool Function(String? text)?)
Callback method to validate if text can be pasted. This is helpful when we need to validate text before pasting. e.g. validate if text is number. Default will be pasted as received.
final
blinkDuration Duration
Blink Duration if blinkWhenObscuring is set to true
final
blinkWhenObscuring bool
Decides whether typed character should be briefly shown before being obscured
final
boxShadows List<BoxShadow>?
Box Shadow for Pincode
final
controller TextEditingController?
TextEditingController to control the text manually. Sets a default TextEditingController() object if none given
final
cursorColor Color?
The color of the cursor, default to Theme.of(context).accentColor
final
cursorHeight double?
Height of the cursor, default to FontSize + 8;
final
cursorWidth double
width of the cursor, default to 2
final
dialogConfig DialogConfig?
Configuration for paste dialog. Read more DialogConfig
final
enableActiveFill bool
Enabled Color fill for individual pin fields, default is false
final
enabled bool
Enable or disable the Field. Default is true
final
enablePinAutofill bool
Enables pin autofill for TextFormField. Default is true
final
errorAnimationController StreamController<ErrorAnimationType>?
Triggers the error animation
final
errorAnimationDuration int
Error animation duration
final
errorTextDirection TextDirection
TextDirection to control a direction in which text flows. Default is TextDirection.ltr
final
errorTextMargin EdgeInsets
Margin for the error text Default is EdgeInsets.zero.
final
errorTextSpace double
The vertical padding from the PinCodeTextField to the error text Default is 16.
final
focusNode FocusNode?
Should pass a FocusNode to manage it from the parent
final
hapticFeedbackTypes HapticFeedbackTypes
Haptic Feedback Types
final
hashCode int
The hash code for this object.
no setterinherited
hintCharacter String?
Displays a hint or placeholder in the field if it's value is empty. It only appears if it's not null. Single character is recommended.
final
hintStyle TextStyle?
the style of the hintCharacter, default is fontSize: 20, fontWeight: FontWeight.bold and it also uses the textStyle's properties TextStyle.color is Colors.grey
final
inputFormatters List<TextInputFormatter>
A list of TextInputFormatter that goes to the TextField
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
keyboardAppearance Brightness?
Brightness dark or light choices for iOS keyboard.
final
keyboardType TextInputType
TextInputType for the pin code fields. default is TextInputType.visiblePassword
final
length int
length of how many cells there should be. 3-8 is recommended by me
final
mainAxisAlignment MainAxisAlignment
This defines how the elements in the pin code field align. Default to MainAxisAlignment.spaceBetween
final
obscureText bool
you already know what it does i guess :P default is false
final
obscuringCharacter String
Character used for obscuring text if obscureText is true.
final
obscuringWidget Widget?
Widget used to obscure text
final
onAutoFillDisposeAction AutofillContextAction
Autofill cleanup action
final
onChanged ValueChanged<String>?
returns the current typed text in the fields
final
onCompleted ValueChanged<String>?
returns the typed text when all pins are set
final
onEditingComplete VoidCallback?
The onEditingComplete callback also runs when the user finishes editing. It's different from onSubmitted because it has a default value which updates the text controller and yields the keyboard focus. Applications that require different behavior can override the default onEditingComplete callback.
final
onSaved FormFieldSetter<String>?
An optional method to call with the final value when the form is saved via FormState.save.
final
onSubmitted ValueChanged<String>?
returns the typed text when user presses done/next action on the keyboard
final
onTap Function?
Method for detecting a pin_code form tap work with all form windows
final
pastedTextStyle TextStyle?
the style of the pasted text, default is fontWeight: FontWeight.bold while TextStyle.color is ThemeData.colorScheme.onSecondary
final
pinTheme PinTheme
Theme for the pin cells. Read more PinTheme
final
readOnly bool
Makes the pin cells readOnly
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scrollPadding EdgeInsets
ScrollPadding follows the same property as TextField's ScrollPadding, default to const EdgeInsets.all(20),
final
separatorBuilder IndexedWidgetBuilder?
Builds separator children
final
showCursor bool
Whether to show cursor or not
final
textCapitalization TextCapitalization
Configures how the platform keyboard will select an uppercase or lowercase keyboard. Only supports text keyboards, other keyboard types will ignore this configuration. Capitalization is locale-aware.
final
textGradient Gradient?
Text gradient for Pincode
final
textInputAction TextInputAction
final
textStyle TextStyle?
the style of the text, default is fontSize: 20, fontWeight: FontWeight.bold
final
useExternalAutoFillGroup bool
Use external AutoFillGroup
final
useHapticFeedback bool
Whether to use haptic feedback or not
final
validator FormFieldValidator<String>?
Validator for the TextFormField
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → _PinCodeTextFieldState
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}) 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