@@ -71,12 +71,17 @@ class FormBuilderFieldState<F extends FormBuilderField<T>, T>
7171 FormBuilderState ? _formBuilderState;
7272 bool _touched = false ;
7373 bool _dirty = false ;
74+
75+ /// The focus node that is used to focus this field.
7476 late FocusNode effectiveFocusNode;
77+
78+ /// The focus attachment for the [effectiveFocusNode] .
7579 FocusAttachment ? focusAttachment;
7680
7781 @override
7882 F get widget => super .widget as F ;
7983
84+ /// Returns the parent [FormBuilderState] if it exists.
8085 FormBuilderState ? get formState => _formBuilderState;
8186
8287 /// Returns the initial value, which may be declared at the field, or by the
@@ -91,18 +96,33 @@ class FormBuilderFieldState<F extends FormBuilderField<T>, T>
9196 widget.valueTransformer == null ? value : widget.valueTransformer !(value);
9297
9398 @override
99+
100+ /// Returns the current error text,
101+ /// which may be a validation error or a custom error text.
94102 String ? get errorText => super .errorText ?? _customErrorText;
95103
96104 @override
105+
106+ /// Returns `true` if the field has an error or has a custom error text.
97107 bool get hasError => super .hasError || errorText != null ;
98108
99109 @override
110+
111+ /// Returns `true` if the field is valid and has no custom error text.
100112 bool get isValid => super .isValid && _customErrorText == null ;
101113
114+ /// Returns `true` if the field is valid.
102115 bool get valueIsValid => super .isValid;
116+
117+ /// Returns `true` if the field has an error.
103118 bool get valueHasError => super .hasError;
104119
120+ /// Returns `true` if the field is enabled and the parent FormBuilder is enabled.
105121 bool get enabled => widget.enabled && (_formBuilderState? .enabled ?? true );
122+
123+ /// Returns `true` if the field is read only.
124+ ///
125+ /// See [FormBuilder.skipDisabled] for more information.
106126 bool get readOnly => ! (_formBuilderState? .widget.skipDisabled ?? false );
107127
108128 /// Will be true if the field is dirty
@@ -199,6 +219,10 @@ class FormBuilderFieldState<F extends FormBuilderField<T>, T>
199219 }
200220
201221 @override
222+
223+ /// Reset field value to initial value
224+ ///
225+ /// Also reset custom error text if exists, and set [isDirty] to `false` .
202226 void reset () {
203227 super .reset ();
204228 didChange (initialValue);
@@ -276,10 +300,12 @@ class FormBuilderFieldState<F extends FormBuilderField<T>, T>
276300 );
277301 }
278302
303+ /// Focus field
279304 void focus () {
280305 FocusScope .of (context).requestFocus (effectiveFocusNode);
281306 }
282307
308+ /// Scroll to show field
283309 void ensureScrollableVisibility () {
284310 Scrollable .ensureVisible (context);
285311 }
0 commit comments