OtpCodeBoxes class
The text fields of a code entered one digit per box. Used by every code screen controller, so typing, paste and clearing behave the same.
Give each box maxLength: length (not 1), so a whole pasted code
reaches onDigitChanged, and AutofillHints.oneTimeCode for the
keyboard's code suggestion.
Constructors
- OtpCodeBoxes({required int length, VoidCallback? onCompleted})
Properties
- code → String
-
The digits typed so far, in box order.
no setter
-
controllers
→ List<
TextEditingController> -
final
-
focusNodes
→ List<
FocusNode> -
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isComplete → bool
-
no setter
- length → int
-
Number of boxes (digits in a code).
final
- onCompleted → VoidCallback?
-
Runs when every box has a digit (auto submit). Null = do nothing.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
clear(
) → void - Empties every box and puts the cursor in the first one (wrong code).
-
dispose(
) → void -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onDigitChanged(
int index, String value) → void -
Call from box
index'sonChanged. Typing moves to the next box; a pasted or autofilled code fills every box. -
onDigitDeleted(
int index) → void -
Call when backspace is pressed in an empty box
index. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited