I'm wondering, can you validate an email without the .com as invalid in Flutter
Example:
johnny@gmail.com = true
johnny@johnny    = false
I'm wondering, can you validate an email without the .com as invalid in Flutter
Example:
johnny@gmail.com = true
johnny@johnny    = false
 
    
    What I use for my email validators is this:
String? validateEmail(String email) {
    const String 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,}))$';
    final RegExp regex = RegExp(pattern);
    if (email.isEmpty || !regex.hasMatch(email)) {
      return 'Invalid email';
    } else {
      return null;
    }
  }
hope it helps.
Example:
johnny@gmail.com = true
johnny@johnny.co    = true
johnny@johnny    = false
johnny@    = false
johnny    = false
johnny@johnny.c    = false
 
    
    Try the following code you can import this class in to the page you want u can just validate any String like following
extension EmailValidator on String {
     bool isValidEmail() {
        return RegExp(
           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,}))$')
      .hasMatch(this);
                     }
               }
      
eg:if(anyString.isValidEmail()) { print("Valid")}
