DefaultTextField class
A customizable text field widget with search, password, and accessibility features.
DefaultTextField provides a flexible text input widget with:
- Password visibility toggle
- Search icon prefix
- Country code prefix support
- Right accessory icons
- Multi-line support with expansion
- Customizable styling and keyboard types
This widget automatically applies consistent styling from Utils.appConstants and provides common text field functionality needed across the application.
Example:
// Basic text field
DefaultTextField(
hintText: 'Enter your name',
mainController: nameController,
onChanged: (value) => print(value),
);
// Password field
DefaultTextField(
hintText: 'Enter password',
isSecureText: true,
isShowPrefixIcon: false,
mainController: passwordController,
);
// Search field
DefaultTextField(
hintText: 'Search...',
keyboardType: TextInputType.text,
inputAction: TextInputAction.search,
onSubmitted: (query) => performSearch(query),
);
// Multi-line text area
DefaultTextField(
hintText: 'Enter description',
maxLines: 5,
isShowPrefixIcon: false,
);
See also:
- TextField for the underlying Flutter widget
- RtCommonWidget.getSearchbar for specialized search fields
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- DefaultTextField
- Available extensions
Constructors
- DefaultTextField({Key? key, dynamic onChanged(String)?, String? hintText, FocusNode? focusValue, TextEditingController? mainController, bool enabled = true, bool isSecureText = false, bool isRightAccessoryIcon = false, bool isShowCountryCodePrefixIcon = false, bool isShowPrefixIcon = true, String imageAssetPath = "", double leftPadding = 20, double rightPadding = 20, bool expand = false, int maxLines = 1, dynamic onSubmitted(String)?, TextInputType keyboardType = TextInputType.text, TextInputAction? inputAction})
-
Creates a default text field widget.
const
Properties
- enabled → bool
-
Whether the text field is enabled for input.
final
- expand → bool
-
Whether the text field should expand to fill available vertical space.
final
- focusValue → FocusNode?
-
FocusNode for managing keyboard focus.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hintText → String?
-
Placeholder text shown when the field is empty.
final
- imageAssetPath → String
-
Path to a custom image asset for the prefix icon.
final
- inputAction → TextInputAction?
-
The action button to show on the keyboard.
final
- isRightAccessoryIcon → bool
-
Whether to show a right chevron accessory icon.
final
- isSecureText → bool
-
Whether to obscure text (for password fields).
final
- isShowCountryCodePrefixIcon → bool
-
Whether to display country code prefix icon.
final
- isShowPrefixIcon → bool
-
Whether to display the search icon prefix.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- keyboardType → TextInputType
-
The type of keyboard to display.
final
- leftPadding → double
-
Left padding of the text field.
final
- mainController → TextEditingController?
-
Controller for reading and controlling the text content.
final
- marginZero → Widget
-
Available on Widget, provided by the WidgetMarginX extension
no setter - maxLines → int
-
Maximum number of lines. Set to -1 for unlimited lines.
final
- onChanged → dynamic Function(String)?
-
Callback function invoked when the text changes.
final
- onSubmitted → dynamic Function(String)?
-
Callback invoked when the user submits the text.
final
- paddingZero → Widget
-
Available on Widget, provided by the WidgetPaddingX extension
no setter - rightPadding → double
-
Right padding of the text field.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sliverBox → Widget
-
Available on Widget, provided by the WidgetSliverBoxX extension
no setter
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< DefaultTextField> -
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
-
marginAll(
double margin) → Widget -
Available on Widget, provided by the WidgetMarginX extension
-
marginOnly(
{double left = 0.0, double top = 0.0, double right = 0.0, double bottom = 0.0}) → Widget -
Available on Widget, provided by the WidgetMarginX extension
-
marginSymmetric(
{double horizontal = 0.0, double vertical = 0.0}) → Widget -
Available on Widget, provided by the WidgetMarginX extension
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
paddingAll(
double padding) → Widget -
Available on Widget, provided by the WidgetPaddingX extension
-
paddingOnly(
{double left = 0.0, double top = 0.0, double right = 0.0, double bottom = 0.0}) → Widget -
Available on Widget, provided by the WidgetPaddingX extension
-
paddingSymmetric(
{double horizontal = 0.0, double vertical = 0.0}) → Widget -
Available on Widget, provided by the WidgetPaddingX 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
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited