Skip to content

Commit 3c663fd

Browse files
feat: add properties documentation
1 parent d2cd50b commit 3c663fd

File tree

6 files changed

+35
-0
lines changed

6 files changed

+35
-0
lines changed

lib/src/extensions/generic_validator.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
extension GenericValidator<T> on T? {
2+
/// Check if the value is empty in a generic way
23
bool emptyValidator() {
34
if (this == null) return true;
45
if (this is Iterable) return (this as Iterable).isEmpty;

lib/src/form_builder_field.dart

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

lib/src/form_builder_field_decoration.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class FormBuilderFieldDecorationState<F extends FormBuilderFieldDecoration<T>,
3535
@override
3636
F get widget => super.widget as F;
3737

38+
/// Get the decoration with the current state
3839
InputDecoration get decoration => widget.decoration.copyWith(
3940
// Read only allow show error to support property skipDisabled
4041
errorText: widget.enabled || readOnly

lib/src/form_builder_field_option.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import 'package:flutter/widgets.dart';
55
/// The type `T` is the type of the value the entry represents. All the entries
66
/// in a given menu must represent values with consistent types.
77
class FormBuilderFieldOption<T> extends StatelessWidget {
8+
/// The widget to display in list of options.
89
final Widget? child;
10+
11+
/// The value of the option.
912
final T value;
1013

1114
/// Creates an option for fields with selection options

lib/src/options/form_builder_chip_option.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'package:flutter_form_builder/flutter_form_builder.dart';
66
/// The type `T` is the type of the value the entry represents. All the entries
77
/// in a given menu must represent values with consistent types.
88
class FormBuilderChipOption<T> extends FormBuilderFieldOption<T> {
9+
/// The avatar to display in list of options.
910
final Widget? avatar;
1011

1112
/// Creates an option for fields with selection options

lib/src/widgets/grouped_checkbox.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ class GroupedCheckbox<T> extends StatelessWidget {
2323
/// The color to use when this checkbox is checked.
2424
///
2525
/// Defaults to [ColorScheme.secondary].
26+
///
27+
/// If [fillColor] returns a non-null color in the [WidgetState.selected]
28+
/// state, it will be used instead of this color.
2629
final Color? activeColor;
2730
final VisualDensity? visualDensity;
2831

0 commit comments

Comments
 (0)