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;
}

Constructors

FormController(BuildContext context)

Properties

context BuildContext
getter/setter pair
formaters List<String>
A string mask to format input strings.
no setter
hashCode int
The hash code for this object.
no setterinherited
regexFilter RegExp
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?
Specifies the type of keyboard input for text fields.
no setter
validator String? Function(String? value)?
A function that validates the input value.
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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