Created
April 6, 2019 12:20
-
-
Save gireesh092/46f1b0862e5d20c64b7b6395a923fdef to your computer and use it in GitHub Desktop.
flutter email validation
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 value) { | |
Pattern pattern = | |
r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$'; | |
RegExp regExp = new RegExp(pattern); | |
if (value.isEmpty) { | |
return "Please enter an E-Mail ID."; | |
} else if (!regExp.hasMatch(value)) { | |
return "Invalid E-Mail address."; | |
} else { | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment