Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Validate email address in Dart? [duplicate]

According to RegExp documentation, we must use JavaScript (Perl 5) regular expressions : ECMA Specification. What pattern do you use for email validation in Dart? Is there any different way than JavaScript to achieve this in Dart?

like image 950
Eric Lavoie Avatar asked May 28 '13 20:05

Eric Lavoie


People also ask

How do I check if my email address is valid on Flutter?

Validating the Email Address with email_validator :The static method validate() in the EmailValidator class will be used to validate the email address. It returns a bool value; if the email address is valid, the returned value is true; otherwise, the returned value is false.

How do I validate my email in TextFormField?

To validate the form, you can use the autovalidate flag and set up a validator for email. There are many options, including regex or manually writing your own checker, but there are also packages available which implement email checking already. For example, https://pub.dev/packages/email_validator.


1 Answers

For that simple regex works pretty good.

var email = "[email protected]" bool emailValid = RegExp(r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+").hasMatch(email); 
like image 97
Airon Tark Avatar answered Oct 28 '22 10:10

Airon Tark