MyTextField class
A customized text field widget that wraps TextField with common styling options.
Provides convenient parameters for label, hint, icons, border, etc., while allowing for full customization by passing a custom InputDecoration.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- MyTextField
- Available extensions
Constructors
-
MyTextField.new({Key? key, TextEditingController? controller, String? label, String? hint, IconData? iconData, Widget? prefixIcon, Widget? suffixIcon, Widget? suffixWidget, VoidCallback? onClick, ValueChanged<
String> ? onSubmitted, bool border = true, bool enabled = true, bool readOnly = false, bool obscureText = false, bool autofocus = false, int? minLines, int? maxLines = 1, TextInputType? keyboardType, TextInputAction? textInputAction, TextCapitalization textCapitalization = TextCapitalization.sentences, InputDecoration? inputDecoration, TextStyle? hintStyle}) -
Creates a customized text field.
const
Properties
- autofocus → bool
-
Whether this text field should focus itself if nothing else is already focused. Defaults to false.
final
- border → bool
-
Whether to show an
OutlineInputBorder
orInputBorder.none
.final - controller → TextEditingController?
-
Controls the text being edited.
final
- enabled → bool
-
Whether the text can be changed. Defaults to true.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hint → String?
-
Text that suggests what sort of input the field accepts.
final
- hintStyle → TextStyle?
-
Overrides the hint style. If not provided, merges a default
font variation with the theme's hint style.
final
- iconData → IconData?
-
Optional icon to display before the input field and outside the border.
Use this OR prefixIcon, not both.
final
- inputDecoration → InputDecoration?
-
Overrides the default generated InputDecoration.
If provided, parameters like label, hint, iconData, prefixIcon,
suffixIcon, suffixWidget, and border are ignored.
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.
final
- label → String?
-
Optional text to display above the text field.
final
- maxLines → int?
-
The maximum number of lines to occupy. Defaults to 1.
final
- minLines → int?
-
The minimum number of lines to occupy. Null means default behavior (usually 1).
final
- obscureText → bool
-
Whether to hide the text being edited (e.g., for passwords). Defaults to false.
final
- onClick → VoidCallback?
-
Called when the user taps this text field.
final
-
onSubmitted
→ ValueChanged<
String> ? -
Called when the user indicates that they are done editing the text in the field.
final
- prefixIcon → Widget?
-
Optional widget to display before the input field and inside the border.
Use this OR iconData, not both.
final
- readOnly → bool
-
Whether the text field is read-only. Defaults to false.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- suffixIcon → Widget?
-
Optional widget to display after the input field and inside the border.
Use this OR suffixWidget, not both.
final
- suffixWidget → Widget?
-
Optional widget to display inline at the end of the text field.
Use this OR suffixIcon, not both.
final
- textCapitalization → TextCapitalization
-
Configures how the platform keyboard behaves regarding capitalization.
final
- textInputAction → TextInputAction?
-
The type of action button to use for the keyboard.
final
Methods
-
align(
[Alignment alignment = Alignment.center]) → Widget -
Available on Widget, provided by the WidgetExtension extension
Wraps the widget in an Align widget with the given alignment. -
animatedOpacity(
{required double opacity, required Duration duration, Curve curve = Curves.linear}) → Widget -
Available on Widget, provided by the WidgetExtension extension
Wraps the widget in an AnimatedOpacity for animated opacity changes. -
animatedSize(
{required Duration duration, Curve curve = Curves.linear, AlignmentGeometry alignment = Alignment.center}) → Widget -
Available on Widget, provided by the WidgetExtension extension
Wraps the widget in an AnimatedSize for animated size changes. -
asSliver(
) → Widget -
Available on Widget, provided by the WidgetExtension extension
Wraps the widget in a SliverToBoxAdapter for use in a CustomScrollView. -
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
center(
) → Widget -
Available on Widget, provided by the WidgetExtension extension
Wraps the widget in a Center widget. -
clippedOval(
{Clip clipBehavior = Clip.antiAlias}) → Widget -
Available on Widget, provided by the WidgetExtension extension
Wraps the widget in a ClipOval for an oval or circular clip. -
clippedRRect(
{required BorderRadiusGeometry borderRadius, Clip clipBehavior = Clip.antiAlias}) → Widget -
Available on Widget, provided by the WidgetExtension extension
Wraps the widget in a ClipRRect with the given border radius. -
constrained(
{double minWidth = 0.0, double maxWidth = double.infinity, double minHeight = 0.0, double maxHeight = double.infinity}) → Widget -
Available on Widget, provided by the WidgetExtension extension
Wraps the widget in a ConstrainedBox to apply constraints. -
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
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
-
decorated(
{required Decoration decoration}) → Widget -
Available on Widget, provided by the WidgetExtension extension
Wraps the widget in a DecoratedBox with the given decoration. -
expand(
[int flex = 1]) → Widget -
Available on Widget, provided by the WidgetExtension extension
Wraps the widget in an Expanded widget with the given flex. -
flexible(
{int flex = 1, FlexFit fit = FlexFit.loose}) → Widget -
Available on Widget, provided by the WidgetExtension extension
Wraps the widget in a Flexible widget with the given flex and fit. -
height(
[double value = double.infinity]) → Widget -
Available on Widget, provided by the WidgetExtension extension
Wraps the widget in a SizedBox to set its height. -
hero(
{required String tag}) → Widget -
Available on Widget, provided by the WidgetExtension extension
Wraps the widget in a Hero widget for animated transitions. -
loadingEffect(
) → Widget -
Available on Widget, provided by the WidgetExtension extension
Wraps the widget in a MyLoadingEffect widget. -
m(
[double n = 16.0]) → Widget -
Available on Widget, provided by the WidgetExtension extension
Wraps the widget in a Container with margin on all sides. -
mb(
[double n = 16.0]) → Widget -
Available on Widget, provided by the WidgetExtension extension
Applies bottom margin to the widget. -
ml(
[double n = 16.0]) → Widget -
Available on Widget, provided by the WidgetExtension extension
Applies left margin to the widget. -
mOnly(
{double l = 0.0, double t = 0.0, double r = 0.0, double b = 0.0}) → Widget -
Available on Widget, provided by the WidgetExtension extension
Applies margin to specific sides of the widget. -
mr(
[double n = 16.0]) → Widget -
Available on Widget, provided by the WidgetExtension extension
Applies right margin to the widget. -
mt(
[double n = 16.0]) → Widget -
Available on Widget, provided by the WidgetExtension extension
Applies top margin to the widget. -
mx(
[double x = 16.0]) → Widget -
Available on Widget, provided by the WidgetExtension extension
Applies horizontal margin to the widget. -
mxy(
[double x = 16.0, double y = 16.0]) → Widget -
Available on Widget, provided by the WidgetExtension extension
Applies horizontal and vertical margin respectively to the widget. -
my(
[double y = 16.0]) → Widget -
Available on Widget, provided by the WidgetExtension extension
Applies vertical margin to the widget. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onTap(
void onTap()?) → Widget -
Available on Widget, provided by the WidgetExtension extension
Wraps the widget in a GestureDetector for tap detection. -
opacity(
[double opacity = 1.0]) → Widget -
Available on Widget, provided by the WidgetExtension extension
Wraps the widget in an Opacity widget. -
p(
[double n = 16.0]) → Widget -
Available on Widget, provided by the WidgetExtension extension
Applies padding to all sides of the widget. -
pb(
[double n = 16.0]) → Widget -
Available on Widget, provided by the WidgetExtension extension
Applies bottom padding to the widget. -
pl(
[double n = 16.0]) → Widget -
Available on Widget, provided by the WidgetExtension extension
Applies left padding to the widget. -
pOnly(
{double l = 0.0, double t = 0.0, double r = 0.0, double b = 0.0}) → Widget -
Available on Widget, provided by the WidgetExtension extension
Applies padding to specific sides of the widget. -
positioned(
{double? left, double? top, double? right, double? bottom, double? width, double? height}) → Widget -
Available on Widget, provided by the WidgetExtension extension
Wraps the widget in a Positioned widget for use in a Stack. -
pr(
[double n = 16.0]) → Widget -
Available on Widget, provided by the WidgetExtension extension
Applies right padding to the widget. -
pt(
[double n = 16.0]) → Widget -
Available on Widget, provided by the WidgetExtension extension
Applies top padding to the widget. -
px(
[double x = 16.0]) → Widget -
Available on Widget, provided by the WidgetExtension extension
Applies horizontal padding to the widget. -
pxy(
[double x = 16.0, double y = 16.0]) → Widget -
Available on Widget, provided by the WidgetExtension extension
Applies horizontal and vertical padding respectively to the widget. -
py(
[double y = 16.0]) → Widget -
Available on Widget, provided by the WidgetExtension extension
Applies vertical padding to the widget. -
rotated(
{required int quarterTurns}) → Widget -
Available on Widget, provided by the WidgetExtension extension
Wraps the widget in a RotatedBox to rotate it by a quarter turn. -
scrollableX(
) → Widget -
Available on Widget, provided by the WidgetExtension extension
Wraps the widget in a SingleChildScrollView for horizontal scrolling. -
scrollableY(
) → Widget -
Available on Widget, provided by the WidgetExtension extension
Wraps the widget in a SingleChildScrollView for vertical scrolling. -
size(
[double value = double.infinity]) → Widget -
Available on Widget, provided by the WidgetExtension extension
Wraps the widget in a SizedBox to set its size (width and height). -
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
tooltip(
String message) → Widget -
Available on Widget, provided by the WidgetExtension extension
Wraps the widget in a Tooltip to display a message on long press or hover. -
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 = true]) → Widget -
Available on Widget, provided by the WidgetExtension extension
Wraps the widget in a Visibility widget. -
width(
[double value = double.infinity]) → Widget -
Available on Widget, provided by the WidgetExtension extension
Wraps the widget in a SizedBox to set its width. -
withAspectRatio(
{required double aspectRatio}) → Widget -
Available on Widget, provided by the WidgetExtension extension
Wraps the widget in an AspectRatio widget.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited