FormController class abstract

Manages form validation and input formatting for a specific form.

  • validator: A function that validates input values. Returns a string error message or null for valid input.
  • regexFilter: A regular expression that defines allowed characters for input validation.
  • formatters: A list of string masks used to format input strings, such as phone numbers or dates.
  • textInputType: Specifies the type of keyboard input for text fields, such as email address, phone number, or regular text. Example usage:
class MyFormController extends FormController {
   Example: Define a validator function
  @override
  String? Function(String? value)? get validator => (value) {
    if (value == null || value.isEmpty) {
      return 'This field cannot be empty';
    }
    return null; // Valid input
  };

   //Example: Define a regular expression filter
  @override
  RegExp get regexFilter => RegExp(r'[a-zA-Z0-9]');

   //Example: Define a list of formatters for input masking
  @override
  List<String> get formatters => [
    "(##) ####-####", // Example phone number mask
  ];

  Example: Define the type of keyboard input for text fields
  @override
  TextInputType? get textInputType => TextInputType.number;
}
Available extensions

Constructors

FormController()

Properties

customFormatters List<TextInputFormatter>
Custom text input formatters.
no setter
formaters List<String>
formaters A string mask to format input strings.
no setter
hashCode int
The hash code for this object.
no setterinherited
helper FormControllerHelper
latefinal
regexFilter RegExp
regexFilter A regular expression that defines the allowed characters for input.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
textInputType TextInputType?
textInputType Specifies the type of keyboard input for text fields.
no setter
validator String? Function(String? value)?
validator A function that validates the input value.
no setter

Methods

formatValue({required String value}) String

Available on FormController, provided by the FormControllerExtension extension

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
resetErrorTracking() → void

Available on FormController, provided by the FormControllerExtension extension

toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

isEmpty(String? value) bool