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?
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.
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.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With