Skip to content

Commit 79db93f

Browse files
committed
Include guide to programmatically inducing errors to README
Request for support in internationalization
1 parent 8386619 commit 79db93f

File tree

1 file changed

+42
-4
lines changed

1 file changed

+42
-4
lines changed

README.md

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ Column(
320320
```
321321

322322
## l10n
323-
Just add the FormBuilderLocalizations.delegate in the list of your app delegates
323+
Just add the `FormBuilderLocalizations.delegate` in the list of your app delegates
324324

325325
```dart
326326
return MaterialApp(
@@ -457,6 +457,40 @@ FormBuilderTextField(
457457
),
458458
```
459459

460+
### Programmatically inducing an error
461+
Declare a variable to hold your error:
462+
```dart
463+
String _emailError;
464+
```
465+
466+
Use the variable as the `errorText` within `InputDecoration`
467+
```dart
468+
FormBuilderTextField(
469+
attribute: 'email',
470+
decoration: InputDecoration(
471+
labelText: 'Email',
472+
errorText: _emailError,
473+
),
474+
validator: FormBuilderValidators.compose([
475+
FormBuilderValidators.required(context),
476+
FormBuilderValidators.email(context),
477+
]),
478+
),
479+
```
480+
481+
Set the error text
482+
```dart
483+
RaisedButton(
484+
child: Text('Submit'),
485+
onPressed: () async {
486+
if(checkIfEmailExists()){
487+
setState(() => _emailError = 'Email already taken.');
488+
}
489+
},
490+
),
491+
```
492+
493+
460494
### Conditional validation
461495
You can also validate a field based on the value of another field
462496
```
@@ -507,9 +541,13 @@ This package is dependent on the following packages and plugins:
507541
* [validators](https://pub.dev/packages/validators) by [dart-league](https://github.com/dart-league)
508542
* [flutter_chips_input](https://pub.dev/packages/flutter_chips_input) & [flutter_touch_spin](https://pub.dev/packages/flutter_touch_spin) by [Yours truly :-)](https://github.com/danvick)
509543

510-
## FUTURE PLANS:
511-
512544
## SUPPORT
513-
If this package was helpful to you in delivering on your project or you just wanna to support this project, a cup of coffee would be highly appreciated ;-)
545+
### PRs
546+
Any kind of support in the form of Pull Requests are always appreciated.
547+
548+
We especially welcome efforts to internationalize/localize the package by translating the default validation error texts.
549+
550+
### Coffee :-)
551+
If this package was helpful to you in delivering your project or you just wanna to support this project, a cup of coffee would be highly appreciated ;-)
514552

515553
[![Buy me a coffee](https://www.buymeacoffee.com/assets/img/custom_images/purple_img.png)](https://buymeacoff.ee/wb5M9y2Sz)

0 commit comments

Comments
 (0)