AdaptiveTextField class

An adaptive text field that automatically handles keyboard type switching and provides built-in UI for users to select different input types.

This widget eliminates the need to manually handle keyboard type logic in every input field by providing a complete solution out of the box.

Example usage:

AdaptiveTextField(
  controller: _controller,
  availableTypes: [
    TextInputType.text,
    TextInputType.number,
    TextInputType.emailAddress,
  ],
)
Inheritance

Constructors

AdaptiveTextField.new({Key? key, required TextEditingController controller, List<TextInputType>? availableTypes, TextInputType? initialType, bool? showTypeSelector, bool obscureText = false, int? maxLines = 1, bool enabled = true, InputDecoration? decoration, String? validator(String?)?, dynamic onChanged(String)?, dynamic onTypeChanged(TextInputType)?, Map<TextInputType, String>? customLabels, List<TextInputFormatter>? inputFormatters})
const

Properties

availableTypes List<TextInputType>?
List of available input types that users can select from. If null or empty, defaults to TextInputType.text.
final
controller TextEditingController
Controls the text being edited in this text field.
final
customLabels Map<TextInputType, String>?
Custom labels for each input type. If not provided, uses default labels.
final
decoration InputDecoration?
Custom decoration for the text field.
final
enabled bool
Whether the text field is enabled for user interaction.
final
hashCode int
The hash code for this object.
no setterinherited
initialType TextInputType?
Initial input type. If not specified, uses the first type from availableTypes.
final
inputFormatters List<TextInputFormatter>?
Optional input formatters to apply to the text input.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
maxLines int?
The maximum number of lines for the text field.
final
obscureText bool
Whether to obscure the text being edited (e.g., for passwords).
final
onChanged → dynamic Function(String)?
Called when the value of the text field changes.
final
onTypeChanged → dynamic Function(TextInputType)?
Called when the input type changes.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
showTypeSelector bool?
Whether to show the input type selector above the field. Defaults to true if more than one type is available.
final
validator String? Function(String?)?
Validator function for form validation.
final

Methods

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