Skip to content

Commit d63b8fa

Browse files
committed
Improved documentation for FormBuilderCustomField
1 parent 990d009 commit d63b8fa

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,10 @@ In order to create an input field in the form, along with the label, and any app
185185
| `valueTransformer` | `ValueTransformer<T>` | `null` | `false` | Function that transforms field value before saving to form value. e.g. transform TextField value for numeric field from `String` to `num` |
186186
The rest of the attributes will be determined by the type of Widget being used.
187187

188-
### Building your own custom `FormField`
188+
### Building your own custom field
189+
To build your own field within a `FormBuilder`, we use `FormBuilderCustomField` which will require that you define your own `FormField`.
190+
The `FormField` will not require a `validator` if the `validators` property is already defined in the `FormBuilderCustomField`.
191+
189192
```dart
190193
FormBuilderCustomField(
191194
attribute: "name",

lib/src/form_builder_custom_field.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,20 @@ import 'package:flutter/material.dart';
22
import 'package:flutter_form_builder/flutter_form_builder.dart';
33

44
class FormBuilderCustomField<T> extends StatefulWidget {
5+
/// Identifier for the field input.
6+
///
7+
/// Used as a key to final map returned when the form is submitted
58
final String attribute;
9+
10+
/// The [FormField] widget that will house the custom input
611
final FormField<T> formField;
12+
13+
/// An optional list of [FormFieldValidator]s that validates the input in the field.
714
final List<FormFieldValidator> validators;
15+
16+
/// Called before field value is submitted.
17+
///
18+
/// Can be used to convert the value to the output expected by the user.
819
final ValueTransformer valueTransformer;
920

1021
FormBuilderCustomField({

0 commit comments

Comments
 (0)