copyWith method

  1. @override
TextFieldState copyWith({
  1. String? value,
  2. String? error,
  3. String? label,
  4. bool? touched,
  5. bool? validateOnUpdate,
  6. List<ValidationRule<String?>>? rules,
})
override

Creates a new FormFieldState object by copying the existing state and replacing the specified fields with new values.

This method returns a new object that has the same state as the current object, except with the updated fields.

value The new value for the form field. error The new error string for the form field. label The new label string for the form field. touched The new boolean value indicating whether the field has been touched. validateOnUpdate The new boolean value to indicate whether to validate on update. rules The new list of ValidationRule objects for the form field.

Returns a new FormFieldState object with updated fields.

Implementation

@override
TextFieldState copyWith({
  String? value,
  String? error,
  String? label,
  bool? touched,
  bool? validateOnUpdate,
  List<ValidationRule<String?>>? rules,
}) {
  return TextFieldState(
    value ?? this.value,
    error: error ?? this.error,
    label: label ?? this.label,
    touched: touched ?? this.touched,
    validateOnUpdate: validateOnUpdate ?? this.validateOnUpdate,
    rules: rules ?? this.rules,
  );
}