Created
October 22, 2020 02:01
-
-
Save rapPayne/9717a930be0e7190e261e7c36442c3c6 to your computer and use it in GitHub Desktop.
Adding focus
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
String _validateEmail(String email) { | |
// 1 | |
RegExp regex = RegExp(r'\w+@\w+\.\w+'); | |
// Add the following line to set focus to the email field | |
if (email.isEmpty || !regex.hasMatch(email)) _emailFocusNode.requestFocus(); | |
// 2 | |
if (email.isEmpty) | |
return 'We need an email address'; | |
else if (!regex.hasMatch(email)) | |
// 3 | |
return "That doesn't look like an email address"; | |
else | |
// 4 | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment