Last active
August 2, 2018 11:45
-
-
Save JulianBissekkou/7a71359b5bc8ef38b2a6c0b862639d58 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
@override | |
void initState() { | |
textFieldController.addListener(() { | |
var email = textFieldController.text; | |
var isValid = EmailValidator.isEmailValid(email); | |
var errorText; | |
if (!isValid) { | |
errorText = "Invalid email"; | |
} | |
setState(() { | |
isEmailValid = isValid; | |
emailErrorText = errorText; | |
}); | |
}); | |
super.initState(); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Row( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
Expanded( | |
child: MyTextField( | |
controller: textFieldController, | |
hintText: "Email", | |
errorText: emailErrorText), | |
), | |
SubmitButton(enabled: isEmailValid), | |
], | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment