Created
July 8, 2020 10:48
-
-
Save pedromassango/edb4b3d2fdef8524e7a2e6f1d664aee7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
//final GlobalKey<FormState> _formState = GlobalKey(); | |
final GlobalKey<FormFieldState> _formFieldState = GlobalKey(); | |
runApp(MaterialApp( | |
title: 'Flutter Demo', | |
theme: ThemeData( | |
visualDensity: VisualDensity.adaptivePlatformDensity, | |
), | |
home: Scaffold( | |
body: Center( | |
child: Form( | |
//key: _formState, | |
autovalidateMode: AutovalidateMode.onUserInteraction, | |
child: Column( | |
children: [ | |
TextFormField( | |
key: _formFieldState, | |
validator: (value) { | |
return 'error1:$value'; | |
}, | |
), | |
TextFormField( | |
validator: (value) { | |
return 'error2:$value'; | |
}, | |
), | |
TextFormField( | |
validator: (value) { | |
return 'error3:$value'; | |
}, | |
), | |
], | |
), | |
), | |
), | |
floatingActionButton: FloatingActionButton( | |
child: Icon(Icons.refresh), | |
onPressed: () { | |
_formFieldState.currentState.reset(); | |
}, | |
), | |
), | |
)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment