FOtpField class
A one-time password input field.
It is a FormField and therefore can be used in a Form widget.
To add a divider in the middle:
FOtpField(
control: .managed(
children: [FOtpItem(), FOtpItem(), FOtpItem(), FOtpDivider(), FOtpItem(), FOtpItem(), FOtpItem()],
),
)
See:
- FOtpController for customizing the behavior of an OTP field.
- FOtpFieldStyle for customizing the appearance of an OTP field.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- FOtpField
- Mixed-in types
Constructors
-
FOtpField({FOtpFieldControl control = const .managed(), FOtpFieldStyleDelta style = const .context(), FFieldBuilder<
FOtpFieldStyle> builder = defaultBuilder, Widget? label, Widget? description, TextMagnifierConfiguration? magnifierConfiguration, Object groupId = EditableText, FocusNode? focusNode, TextInputType? keyboardType = .text, TextInputAction? textInputAction = .done, TextCapitalization textCapitalization = .none, TextDirection? textDirection, bool autofocus = false, WidgetStatesController? statesController, bool readOnly = false, GestureTapCallback? onTap, TapRegionCallback? onTapOutside, bool onTapAlwaysCalled = false, VoidCallback? onEditingComplete, ValueChanged<String> ? onSubmit, AppPrivateCommandCallback? onAppPrivateCommand, List<TextInputFormatter> ? inputFormatters, bool enabled = true, bool? ignorePointers, bool enableInteractiveSelection = true, TextSelectionControls? selectionControls, DragStartBehavior dragStartBehavior = .start, MouseCursor? mouseCursor, Iterable<String> ? autofillHints = const [AutofillHints.oneTimeCode], String? restorationId, bool stylusHandwritingEnabled = true, bool enableIMEPersonalizedLearning = true, ContentInsertionConfiguration? contentInsertionConfiguration, EditableTextContextMenuBuilder? contextMenuBuilder = FTextField.defaultContextMenuBuilder, bool canRequestFocus = true, UndoHistoryController? undoController, FormFieldSetter<String> ? onSaved, VoidCallback? onReset, FormFieldValidator<String> ? validator, AutovalidateMode autovalidateMode = .disabled, String? forceErrorText, Widget errorBuilder(BuildContext context, String message) = FFormFieldProperties.defaultErrorBuilder, Key? formFieldKey, Key? key}) - Creates an FOtpField.
Properties
-
autofillHints
→ Iterable<
String> ? -
A list of strings that helps the autofill service identify the type of this text input.
final
- autofocus → bool
-
Whether this text field should focus itself if nothing else is already focused. Defaults to false.
final
- autovalidateMode → AutovalidateMode
-
Used to enable/disable this form field's auto validation and update its error text.
final
-
builder
→ FFieldBuilder<
FOtpFieldStyle> -
The builder used to decorate the text-field. It should always use the given child.
final
- canRequestFocus → bool
-
Determine whether this text field can request the primary focus.
final
- contentInsertionConfiguration → ContentInsertionConfiguration?
-
Configuration of handler for media content inserted via the system input method.
final
- contextMenuBuilder → EditableTextContextMenuBuilder?
-
Builds the text selection toolbar when requested by the user.
final
- control → FOtpFieldControl
-
Defines how the OTP field's state is controlled.
final
- description → Widget?
-
The description.
final
- dragStartBehavior → DragStartBehavior
-
Determines the way that drag start behavior is handled. By default, the drag start behavior is DragStartBehavior.start.
final
- enabled → bool
-
Whether the form is able to receive user input.
final
- enableIMEPersonalizedLearning → bool
-
Whether to enable that the IME update personalized data such as typing history and user dictionary data.
final
- enableInteractiveSelection → bool
-
Whether to enable user interface affordances for changing the text selection. Defaults to true.
final
- errorBuilder → Widget Function(BuildContext context, String message)
-
The builder for errors displayed below the description. Defaults to displaying the error message.
final
- focusNode → FocusNode?
-
Defines the keyboard focus for this FTextField.
final
- forceErrorText → String?
-
An optional property that forces the FormFieldState into an error state by directly setting the
FormFieldState.errorText property without running the validator function.
final
- formFieldKey → Key?
-
The key to use for the internal FormField.
final
- groupId → Object
-
The group identifier for the TextFieldTapRegion of this text field.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- ignorePointers → bool?
-
Determines whether this widget ignores pointer events. Defaults to null, and when null, does nothing.
final
-
inputFormatters
→ List<
TextInputFormatter> ? -
Optional input validation and formatting overrides.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- keyboardType → TextInputType?
-
The type of keyboard to use for editing the text. Defaults to TextInputType.text.
final
- label → Widget?
-
The label.
final
- magnifierConfiguration → TextMagnifierConfiguration?
-
The configuration for the magnifier of this text field.
final
- mouseCursor → MouseCursor?
-
The cursor for a mouse pointer when it enters or is hovering over the widget.
final
- onAppPrivateCommand → AppPrivateCommandCallback?
-
This is used to receive a private command from the input method.
final
- onEditingComplete → VoidCallback?
-
Called when the user submits editable content (e.g., user presses the "done" button on the keyboard).
final
- onReset → VoidCallback?
-
An optional method to call when the form field is reset via FormFieldState.reset.
final
-
onSaved
→ FormFieldSetter<
String> ? -
An optional method to call with the final value when the form is saved via FormState.save.
final
-
onSubmit
→ ValueChanged<
String> ? -
Called when the user indicates that they are done editing the text in the field.
final
- onTap → GestureTapCallback?
-
Called for the first tap in a series of taps.
final
- onTapAlwaysCalled → bool
-
Whether onTap should be called for every tap.
final
- onTapOutside → TapRegionCallback?
-
Called for each tap down that occurs outside of the TextFieldTapRegion
group when the text field is focused.
final
- readOnly → bool
-
Whether the text can be changed. Defaults to false.
final
- restorationId → String?
-
Restoration ID to save and restore the state of the text field.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- selectionControls → TextSelectionControls?
-
Optional delegate for building the text selection handles.
final
- statesController → WidgetStatesController?
-
Represents the interactive "state" of this widget in terms of a set of WidgetStates, including
WidgetState.disabled, WidgetState.hovered, WidgetState.error, and WidgetState.focused.
final
- style → FOtpFieldStyleDelta
-
The style.
final
- stylusHandwritingEnabled → bool
-
Whether this input supports stylus handwriting, where the user can write directly on top of a field.
final
- textCapitalization → TextCapitalization
-
Configures how the platform keyboard will select an uppercase or lowercase keyboard. Defaults to
TextCapitalization.none.
final
- textDirection → TextDirection?
-
The directionality of the text. Defaults to the ambient Directionality, if any.
final
- textInputAction → TextInputAction?
-
The type of action button to use for the keyboard.
final
- undoController → UndoHistoryController?
-
Controls the undo state.
final
-
validator
→ FormFieldValidator<
String> ? -
An optional method that validates an input. Returns an error string to
display if the input is invalid, or null otherwise.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< FOtpField> -
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.
override
-
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
Static Properties
-
defaultInputFormatters
→ List<
TextInputFormatter> -
The default input formatters that restrict input to digits only.
final
Static Methods
-
defaultBuilder(
BuildContext context, FOtpFieldStyle style, Set< FTextFieldVariant> variants, Widget child) → Widget - The default builder that returns the child as-is.