CodeEntryField class

A Flutter widget for entering single characters at a time in a series of boxes.

This widget provides a flexible and customizable way to input codes, PINs, or any sequence of single characters. Each character has its own dedicated box, and the widget handles focus management, backspace behavior, and character validation.

Inheritance

Constructors

CodeEntryField({Key? key, required int characterCount, required void onChanged(List<String>), Size? boxSize, List<String>? initialCharacters, CodeEntryFieldStyle? style, Capitalization capitalization = Capitalization.keyboardDefined})
Creates a CodeEntryField widget.
const

Properties

boxSize Size?
The size (width and height) of each character box. Defaults to 50.0.
final
capitalization Capitalization
Set the character capitaliztion . Default: keyboadDefined
final
characterCount int
The number of character boxes to display.
final
hashCode int
The hash code for this object.
no setterinherited
initialCharacters List<String>?
An optional list of initial characters to pre-fill the boxes. If the list is longer than characterCount, extra characters are ignored. If shorter, the remaining boxes will be blank.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onChanged → void Function(List<String>)
A callback function that is called whenever the list of characters changes. It provides the current list of characters in all boxes.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
style CodeEntryFieldStyle?
The style to apply to the code entry field.
final

Methods

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