FormifyTextField class

FormifyTextField

FormifyTextField is a custom Flutter widget that extends TextFormField and provides additional configuration options for managing forms. It simplifies form management and allows for easy integration of form fields into your Flutter app.

Constructor:

FormifyTextField({
  Key? key,
  String? label,
  String? initialValue,
  FocusNode? focusNode,
  TextInputType? keyboardType,
  TextCapitalization textCapitalization = TextCapitalization.none,
  TextInputAction? textInputAction,
  bool obscureText = false,
  int? maxLines = 1,
  int? minLines,
  ValueChanged<String>? onChanged,
  GestureTapCallback? onTap,
  ValueChanged<String>? onFieldSubmitted,
  FormFieldSetter<String>? onSaved,
  FormFieldValidator<String>? validator,
  List<TextInputFormatter>? inputFormatters,
  bool? enabled,
  bool readOnly = false,
  AutovalidateMode? autovalidateMode,
  String? hintText,
  Widget? suffixIcon,
  Widget? prefixIcon,
  TextEditingController? controller,
  bool required = false,
  InputDecoration? inputDecoration,
  GlobalKey<FormFieldState>? formKey,
})

Parameters:

  • key (optional): A key to identify the widget.
  • label (optional): The label text displayed above the input field.
  • initialValue (optional): The initial value of the input field.
  • focusNode (optional): The focus node that controls the focus of the input field.
  • keyboardType (optional): The type of keyboard to display (e.g., text, number, email).
  • textCapitalization (optional): The text capitalization style for the input field.
  • textInputAction (optional): The action to be associated with the input field (e.g., next, done).
  • obscureText (optional): Whether the input text should be obscured (e.g., for passwords).
  • maxLines (optional): The maximum number of lines for multiline input.
  • minLines (optional): The minimum number of lines for multiline input.
  • onChanged (optional): Callback function when the input value changes.
  • onTap (optional): Callback function when the input field is tapped.
  • onFieldSubmitted (optional): Callback function when the form field is submitted.
  • onSaved (optional): Callback function for saving the form field's value.
  • validator (optional): Function to validate the input field's value.
  • inputFormatters (optional): List of input formatters for custom input formatting.
  • enabled (optional): Whether the input field is enabled.
  • readOnly (optional): Whether the input field is read-only.
  • autovalidateMode (optional): The mode for automatic validation.
  • hintText (optional): Hint text displayed when the input field is empty.
  • suffixIcon (optional): Widget to be displayed as a suffix icon in the input field.
  • prefixIcon (optional): Widget to be displayed as a prefix icon in the input field.
  • controller (optional): Controller for managing the input field's text.
  • required (optional): Indicates whether the field is required (adds a red asterisk to the label).
  • inputDecoration (optional): Custom input decoration configuration.
  • formKey (optional): Key for linking the FormifyTextField with its parent form.

Methods:

  • copyWith(): Creates a copy of the FormifyTextField with specific configurations.

Usage:

FormifyTextField(
  label: 'Email',
  keyboardType: TextInputType.emailAddress,
  validator: (value) {
    if (value == null || value.isEmpty) {
      return 'Please enter your email address';
    }
    // Additional validation logic
    return null;
  },
  // Add more configuration options as needed
)
Inheritance

Constructors

FormifyTextField({Key? key, String? label, String? initialValue, FocusNode? focusNode, TextInputType? keyboardType, TextCapitalization textCapitalization = TextCapitalization.none, TextInputAction? textInputAction, bool obscureText = false, int? maxLines = 1, int? minLines, ValueChanged<String>? onChanged, GestureTapCallback? onTap, ValueChanged<String>? onFieldSubmitted, FormFieldSetter<String>? onSaved, FormFieldValidator<String>? validator, List<TextInputFormatter>? inputFormatters, bool? enabled, bool readOnly = false, AutovalidateMode? autovalidateMode, String? hintText, Widget? suffixIcon, Widget? prefixIcon, TextEditingController? controller, bool required = false, InputDecoration? inputDecoration, GlobalKey<FormFieldState>? formKey})
const

Properties

autovalidateMode AutovalidateMode?
The mode for automatic validation.
final
controller TextEditingController?
Controller for managing the input field's text.
final
enabled bool?
Whether the input field is enabled.
final
focusNode FocusNode?
The focus node that controls the focus of the input field.
final
formKey GlobalKey<FormFieldState>?
Key for linking the FormifyTextField with its parent form.
final
hashCode int
The hash code for this object.
no setterinherited
hintText String?
Hint text displayed when the input field is empty.
final
iDecoration InputDecoration
iDecoration
no setter
initialValue String?
The initial value of the input field.
final
inputDecoration InputDecoration?
Custom input decoration configuration.
final
inputFormatters List<TextInputFormatter>?
List of input formatters for custom input formatting.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
keyboardType TextInputType?
The type of keyboard to display (e.g., text, number, email).
final
label String?
The label text displayed above the input field.
final
maxLines int?
The maximum number of lines for multiline input.
final
minLines int?
The minimum number of lines for multiline input.
final
mxLine int?
mxLine
no setter
obscureText bool
Whether the input text should be obscured (e.g., for passwords).
final
onChanged ValueChanged<String>?
Callback function when the input value changes.
final
onFieldSubmitted ValueChanged<String>?
Callback function when the form field is submitted.
final
onSaved FormFieldSetter<String>?
Callback function for saving the form field's value.
final
onTap GestureTapCallback?
Callback function when the input field is tapped.
final
prefixIcon Widget?
Widget to be displayed as a prefix icon in the input field.
final
readOnly bool
Whether the input field is read-only.
final
required bool
Indicates whether the field is required (adds a red asterisk to the label).
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
suffixIcon Widget?
Widget to be displayed as a suffix icon in the input field.
final
tCapitalization TextCapitalization
tCapitalization
no setter
textCapitalization TextCapitalization
The text capitalization style for the input field.
final
textInputAction TextInputAction?
The action to be associated with the input field (e.g., next, done).
final
tiAction TextInputAction?
tiAction
no setter
validator FormFieldValidator<String>?
Function to validate the input field's value.
final

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
copyWith({GlobalKey<FormFieldState>? formKey, bool? required, String? label, String? initialValue, FocusNode? focusNode, TextInputType? keyboardType, TextCapitalization? textCapitalization, TextInputAction? textInputAction, bool? obscureText, int? maxLines, int? minLines, ValueChanged<String>? onChanged, GestureTapCallback? onTap, ValueChanged<String>? onFieldSubmitted, FormFieldSetter<String>? onSaved, FormFieldValidator<String>? validator, List<TextInputFormatter>? inputFormatters, bool? enabled, bool? readOnly, AutovalidateMode? autovalidateMode, String? hintText, Widget? suffixIcon, Widget? prefixIcon, TextEditingController? controller, InputDecoration? inputDecoration}) FormifyTextField
Creates a copy of the FormifyTextField with specific configurations.
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
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}) 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