TextFieldState constructor

TextFieldState(
  1. String? value, {
  2. required String label,
  3. String? error,
  4. List<ValidationRule<String?>> rules = const [],
  5. bool validateOnUpdate = true,
  6. bool touched = false,
  7. TextEditingController? controller,
  8. FocusNode? focusNode,
})

Creates a new instance of TextFieldState.

  • value: The initial value of the text input field.
  • label: The label or name of the text input form field (required).
  • rules: The list of validation rules to apply to the text field (default is an empty list).
  • validateOnUpdate: Indicates whether validation should occur on updates (default is true).
  • touched: Indicates whether the field has been touched (interacted with) by the user (default is false).
  • controller: Optionally provide your own TextEditingController. If not provided, one will be created.

Implementation

TextFieldState(
  String? value, {
  required String label,
  String? error,
  List<ValidationRule<String?>> rules = const [],
  bool validateOnUpdate = true,
  bool touched = false,
  widgets.TextEditingController? controller,
  widgets.FocusNode? focusNode,
})  : _controller = controller ??
          widgets.TextEditingController.fromValue(
            widgets.TextEditingValue(
              text: value ?? '',
              selection: value != null
                  ? widgets.TextSelection.collapsed(offset: value.length)
                  : const widgets.TextSelection.collapsed(offset: 0),
            ),
          ),
      _focusNode = focusNode ?? widgets.FocusNode(),
      super(
        value: value,
        error: error,
        label: label,
        rules: rules,
        validateOnUpdate: validateOnUpdate,
        touched: touched,
      );