Created
June 19, 2019 13:40
-
-
Save bettdouglas/dbb5ac36e7b8493882b7ee41f74ea8ae 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
var _formKey = GlobalKey<FormState>(); | |
child: Form( | |
key: _formKey, | |
child: Column( | |
children: <Widget>[ | |
DynamicInput( | |
hint: 'Enter valid name', | |
controller: nameController, | |
label: 'Name', | |
type: DataType.NAME, | |
), | |
DynamicInput( | |
hint: 'Enter valid email', | |
controller: emailController, | |
label: 'Email', | |
type: DataType.EMAIL, | |
), | |
DynamicInput( | |
hint: 'Enter valid age', | |
controller: ageController, | |
label: 'Age:', | |
type: DataType.INTEGER, | |
), | |
DynamicInput( | |
hint: 'Enter valid phone', | |
controller: phoneController, | |
label: 'Phone', | |
type: DataType.PHONE, | |
), | |
RaisedButton( | |
child: Text('Validate'), | |
color: valid ? Colors.green : Colors.red, | |
onPressed: () { | |
if (_formKey.currentState.validate()) { ///validates the form | |
setState(() { | |
valid = true; | |
}); | |
print('Entire form is valid'); | |
} else { | |
print('Some info is not correct'); | |
} | |
}, | |
) | |
], | |
), | |
), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment