TFormField<T> class

A form field wrapper with factory methods for all input types.

TFormField provides a unified interface for creating form fields with:

  • Automatic value binding to TFieldProp
  • Factory methods for all widget types
  • Responsive sizing (sm, md, lg)
  • Integration with TFormBuilder

Factory Methods

  • text() - Text input
  • number() - Number input
  • date() - Date picker
  • time() - Time picker
  • dateTime() - Date-time picker
  • select() - Single selection
  • multiSelect() - Multiple selection
  • toggle() - Switch
  • checkbox() - Checkbox
  • checkboxGroup() - Checkbox group
  • filePicker() - File upload
  • group() - Nested form
  • items() - Dynamic list of forms

Usage Example

final name = TFieldProp<String>('');

TFormField.text(name, 'Name',
  isRequired: true,
  rules: [Validations.required],
).size(6)  // 6 columns on medium screens

Type parameter:

  • T: The type of the field value

See also:

Constructors

TFormField({required Widget builder(ValueChanged<T?> ), required TFieldProp<T> prop})
Creates a form field.

Properties

builder Widget Function(ValueChanged<T?> )
Builder function that creates the widget.
final
hashCode int
The hash code for this object.
no setterinherited
prop TFieldProp<T>
The reactive property for this field.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
size(int md, {int? sm, int? lg}) TFormField<T>
Sets the responsive size of the field.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

checkbox(TFieldProp<bool?> prop, String? label, {FocusNode? focusNode, bool isRequired = false, List<String? Function(bool?)>? rules, bool autoFocus = false, bool disabled = false, Color? color, TInputSize? size}) TFormField<bool?>
checkboxGroup<T>(TFieldProp<List<T>> prop, String? label, List<TCheckboxGroupItem<T>> items, {String? tag, String? helperText, bool isRequired = false, bool disabled = false, bool autoFocus = false, TInputFieldTheme? theme, FocusNode? focusNode, VoidCallback? onTap, List<String? Function(List<T>?)>? rules, Color? color, bool block = true, bool vertical = false}) TFormField<List<T>>
date(TFieldProp<DateTime> prop, String? label, {String? tag, String? placeholder, String? helperText, bool isRequired = false, bool disabled = false, bool autoFocus = false, bool readOnly = false, TTextFieldTheme? theme, FocusNode? focusNode, VoidCallback? onTap, TextEditingController? textController, List<String? Function(DateTime?)>? rules, VoidCallback? onShow, VoidCallback? onHide, DateFormat? format, DateTime? firstDate, DateTime? lastDate}) TFormField<DateTime>
dateTime(TFieldProp<DateTime> prop, String? label, {String? tag, String? placeholder, String? helperText, bool isRequired = false, bool disabled = false, bool autoFocus = false, bool readOnly = false, TTextFieldTheme? theme, FocusNode? focusNode, VoidCallback? onTap, TextEditingController? textController, List<String? Function(DateTime?)>? rules, VoidCallback? onShow, VoidCallback? onHide, DateFormat? format, DateTime? firstDate, DateTime? lastDate}) TFormField<DateTime>
filePicker<T>(TFieldProp<List<TFile>> prop, String? label, {String? tag, String? placeholder, String? helperText, bool isRequired = false, bool disabled = false, bool autoFocus = false, TFilePickerTheme? theme, FocusNode? focusNode, VoidCallback? onTap, List<String? Function(List<TFile>?)>? rules, bool allowMultiple = false, List<String>? allowedExtensions, TFileType fileType = TFileType.any}) TFormField<List<TFile>>
group<T extends TFormBase>(TFieldProp<T> prop, {String? label}) TFormField<T>
items<T extends TFormBase>(TFieldProp<List<T>> prop, T onNewItem(), {String? label, String buttonLabel = 'Add New', TItemAddPosition itemAddPosition = TItemAddPosition.first}) TFormField<List<T>>
multiSelect<T, V, K>(TFieldProp<List<V>> prop, String? label, {String? tag, String? placeholder, String? helperText, bool isRequired = false, bool disabled = false, bool autoFocus = false, bool readOnly = false, TTagsFieldTheme? theme, FocusNode? focusNode, VoidCallback? onTap, TTagsController? textController, List<String? Function(List<V>?)>? rules, List<T>? items, ItemKeyAccessor<T, K>? itemKey, ItemValueAccessor<T, V>? itemValue, ItemTextAccessor<T>? itemText, ItemTextAccessor<T>? itemSubText, ItemTextAccessor<T>? itemImageUrl, ItemChildrenAccessor<T>? itemChildren, int itemsPerPage = 10, TLoadListener<T>? onLoad, int? searchDelay}) TFormField<List<V>>
number<T extends num>(TFieldProp<T> prop, String? label, {String? tag, String? placeholder, String? helperText, bool isRequired = false, bool disabled = false, bool autoFocus = false, bool readOnly = false, TNumberFieldTheme? theme, FocusNode? focusNode, VoidCallback? onTap, TextEditingController? textController, List<String? Function(T?)>? rules}) TFormField<T>
select<T, V, K>(TFieldProp<V?> prop, String? label, {String? tag, String? placeholder, String? helperText, bool isRequired = false, bool disabled = false, bool autoFocus = false, bool readOnly = false, TTextFieldTheme? theme, FocusNode? focusNode, VoidCallback? onTap, TextEditingController? textController, List<String? Function(V?)>? rules, List<T>? items, ItemKeyAccessor<T, K>? itemKey, ItemValueAccessor<T, V>? itemValue, ItemTextAccessor<T>? itemText, ItemTextAccessor<T>? itemSubText, ItemTextAccessor<T>? itemImageUrl, ItemChildrenAccessor<T>? itemChildren, int? itemsPerPage = 6, TLoadListener<T>? onLoad, int? searchDelay}) TFormField<V?>
tags(TFieldProp<List<String>> prop, String? label, {String? tag, String? placeholder, String? helperText, bool isRequired = false, bool disabled = false, bool autoFocus = false, bool readOnly = false, TTagsFieldTheme? theme, FocusNode? focusNode, VoidCallback? onTap, TTagsController? textController, List<String? Function(List<String>?)>? rules, String? inputValue, ValueChanged<String>? onInputChanged, bool addTagOnEnter = true}) TFormField<List<String>>
text(TFieldProp<String> prop, String? label, {String? tag, String? placeholder, String? helperText, bool isRequired = false, bool disabled = false, bool autoFocus = false, bool readOnly = false, TTextFieldTheme? theme, FocusNode? focusNode, VoidCallback? onTap, TextEditingController? textController, List<String? Function(String?)>? rules, int rows = 1}) TFormField<String>
time(TFieldProp<TimeOfDay> prop, String? label, {String? tag, String? placeholder, String? helperText, bool isRequired = false, bool disabled = false, bool autoFocus = false, bool readOnly = false, TTextFieldTheme? theme, FocusNode? focusNode, VoidCallback? onTap, TextEditingController? textController, List<String? Function(TimeOfDay?)>? rules, VoidCallback? onShow, VoidCallback? onHide, DateFormat? format}) TFormField<TimeOfDay>
toggle(TFieldProp<bool> prop, String? label, {FocusNode? focusNode, bool isRequired = false, List<String? Function(bool?)>? rules, bool autoFocus = false, bool disabled = false, Color? color, TInputSize? size}) TFormField<bool>