Skip to content

Commit 79d8898

Browse files
committed
chore: released v6.1.0
1 parent 2d95e82 commit 79d8898

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## [6.1.0] - 01-Sep-2021
2+
* When form validation fails, automatically scroll to first error
3+
* New way to programmatically induce custom errors by calling `GlobalKey<FormBuilderState>.invalidateField()` or `GlobalKey<FormBuilderFieldState>.invalidate()`
4+
* Added Arabic and Persian/Farsi locales
5+
* Made maxLines property nullable and added assertions
6+
* Remove field from internal value map on when a field is unregistered
7+
* Fix checkbox issue with null values
8+
19
## [6.0.1] - 19-May-2021
210
* Add whitespace check for required validator
311
* Null-safety and type fixes

README.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,42 @@ FormBuilderTextField(
374374
```
375375

376376
### Programmatically inducing an error
377+
#### Option 1 - Using FormBuilder / FieldBuilderField key
378+
```dart
379+
final _formKey = GlobalKey<FormBuilderState>();
380+
final _emailFieldKey = GlobalKey<FormBuilderFieldState>();
381+
...
382+
FormBuilder(
383+
key: _formKey,
384+
child: Column(
385+
children: [
386+
FormBuilderTextField(
387+
key: _emailFieldKey
388+
name: 'email',
389+
decoration: InputDecoration(labelText: 'Email'),
390+
validator: FormBuilderValidators.compose([
391+
FormBuilderValidators.required(context),
392+
FormBuilderValidators.email(context),
393+
]),
394+
),
395+
RaisedButton(
396+
child: Text('Submit'),
397+
onPressed: () async {
398+
if(await checkIfEmailExists()){
399+
// Either invalidate using Form Key
400+
_formKey.currentState?.invalidateField(name: 'email', errorText: 'Email already taken.');
401+
// OR invalidate using Field Key
402+
_emailFieldKey.currentState?.invalidate('Email already taken.');
403+
}
404+
},
405+
),
406+
],
407+
),
408+
),
409+
410+
```
411+
412+
#### Option 2 - Using InputDecoration.errorText
377413
Declare a variable to hold your error:
378414
```dart
379415
String _emailError;
@@ -400,7 +436,7 @@ RaisedButton(
400436
child: Text('Submit'),
401437
onPressed: () async {
402438
setState(() => _emailError = null);
403-
if(checkIfEmailExists()){
439+
if(await checkIfEmailExists()){
404440
setState(() => _emailError = 'Email already taken.');
405441
}
406442
},

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_form_builder
22
description: This package helps in creation of forms in Flutter by removing the boilerplate code, reusing validation, react to changes, and collect final user input.
3-
version: 6.0.1
3+
version: 6.1.0
44
homepage: https://github.com/danvick/flutter_form_builder
55

66
environment:

0 commit comments

Comments
 (0)