OtpInputWidget class
A row of single-digit input boxes for OTP / PIN entry.
Auto-advances focus on input, supports backspace navigation, and reports the assembled value through onChanged and onCompleted. Pasting a string of digits fills consecutive boxes from the focused one.
OtpInputWidget(
length: 6,
onChanged: (value) {},
onCompleted: (value) => _verify(value),
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- OtpInputWidget
- Available extensions
Constructors
-
OtpInputWidget({Key? key, int length = 6, ValueChanged<
String> ? onChanged, ValueChanged<String> ? onCompleted, double boxWidth = 44, double boxHeight = 52, bool obscureText = false, bool autoFocus = false, String? semanticLabel}) -
Creates an OTP input.
const
Properties
- autoFocus → bool
-
When
truethe field auto-focuses on first build. Defaults tofalse.final - boxHeight → double
-
Logical-pixel height per box. Defaults to 52.
final
- boxWidth → double
-
Logical-pixel width per box. Defaults to 44.
final
- defaultHorizontalSpace → SizedBox
-
Available on Widget, provided by the WidgetExtension extension
no setter - defaultVerticalSpace → SizedBox
-
Available on Widget, provided by the WidgetExtension extension
no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- length → int
-
Number of digit boxes to render. Defaults to 6.
final
- obscureText → bool
-
When
truethe input is rendered as obscured dots (use for PIN entry). Defaults tofalse.final -
onChanged
→ ValueChanged<
String> ? -
Called on every keystroke with the current concatenated value.
May be shorter than length until the user finishes.
final
-
onCompleted
→ ValueChanged<
String> ? -
Called once when the user has filled every box.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- semanticLabel → String?
-
Optional accessibility label announced for the whole OTP row.
final
Methods
-
center(
) → Center -
Available on Widget, provided by the WidgetExtension extension
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< OtpInputWidget> -
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
-
lightGreyBackground(
{required BuildContext context}) → Container -
Available on Widget, provided by the WidgetExtension extension
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onTap(
GestureTapCallback callback, {VoidCallback? onLongPress}) → InkWell -
Available on Widget, provided by the WidgetExtension extension
-
padAll(
{double? value}) → Padding -
Available on Widget, provided by the WidgetExtension extension
-
padBottom(
{double? bottom}) → Padding -
Available on Widget, provided by the WidgetExtension extension
-
padHorizontal(
{double? horizontal}) → Padding -
Available on Widget, provided by the WidgetExtension extension
-
padLeft(
{double? left}) → Padding -
Available on Widget, provided by the WidgetExtension extension
-
padRight(
{double? right}) → Padding -
Available on Widget, provided by the WidgetExtension extension
-
padTop(
{double? top}) → Padding -
Available on Widget, provided by the WidgetExtension extension
-
padVertical(
{double? vertical}) → Padding -
Available on Widget, provided by the WidgetExtension extension
-
padZero(
) → Padding -
Available on Widget, provided by the WidgetExtension extension
-
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
-
visible(
bool visible, {Widget? defaultWidget}) → Widget -
Available on Widget, provided by the WidgetExtension extension
set visibility
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited