Skip to content

Commit a97250f

Browse files
committed
chore(core): added link in readme to article with custom field instructions
1 parent 01b2a8f commit a97250f

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

packages/flutter_form_builder/README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ___
1818
___
1919

2020
### Example
21-
```dart
21+
```Dart
2222
import 'package:flutter_form_builder/flutter_form_builder.dart';
2323
2424
...
@@ -238,11 +238,12 @@ The rest of the attributes will be determined by the type of Widget being used.
238238

239239
### Building your own custom field
240240
To build your own field within a `FormBuilder`, we use `FormBuilderField` which will require that you define your own field.
241-
```dart
241+
Read [this article](https://medium.com/@danvickmiller/building-a-custom-flutter-form-builder-field-c67e2b2a27f4) for step-by-step instructions on how to build your own custom field.
242+
```Dart
242243
var options = ["Option 1", "Option 2", "Option 3"];
243244
```
244245

245-
```dart
246+
```Dart
246247
FormBuilderField(
247248
name: "name",
248249
validator: FormBuilderValidators.compose([
@@ -274,11 +275,11 @@ FormBuilderField(
274275

275276
### Programmatically changing field value
276277
You can either change the value of one field at a time like so:
277-
```dart
278+
```Dart
278279
_formKey.currentState.fields['color_picker'].didChange(Colors.black);
279280
```
280281
Or multiple fields value like so:
281-
```dart
282+
```Dart
282283
_formKey.currentState.patchValue({
283284
'age': '50',
284285
'slider': 6.7,
@@ -293,7 +294,7 @@ _formKey.currentState.patchValue({
293294

294295
### Programmatically inducing an error
295296
#### Option 1 - Using FormBuilder / FieldBuilderField key
296-
```dart
297+
```Dart
297298
final _formKey = GlobalKey<FormBuilderState>();
298299
final _emailFieldKey = GlobalKey<FormBuilderFieldState>();
299300
...
@@ -329,12 +330,12 @@ FormBuilder(
329330

330331
#### Option 2 - Using InputDecoration.errorText
331332
Declare a variable to hold your error:
332-
```dart
333+
```Dart
333334
String _emailError;
334335
```
335336

336337
Use the variable as the `errorText` within `InputDecoration`
337-
```dart
338+
```Dart
338339
FormBuilderTextField(
339340
name: 'email',
340341
decoration: InputDecoration(
@@ -349,7 +350,7 @@ FormBuilderTextField(
349350
```
350351

351352
Set the error text
352-
```dart
353+
```Dart
353354
RaisedButton(
354355
child: Text('Submit'),
355356
onPressed: () async {
@@ -363,7 +364,7 @@ RaisedButton(
363364

364365
### Conditional validation
365366
You can also validate a field based on the value of another field
366-
```dart
367+
```Dart
367368
FormBuilderRadioGroup(
368369
decoration: InputDecoration(labelText: 'My best language'),
369370
name: 'my_language',

0 commit comments

Comments
 (0)