Flutter Email Validator

Flutter Email Validator:

In this tutorial, we are going to validate the email address. Email validation is a procedure, that verifies the email Id. If the email is deliverable then it is valid. email validation also confirms that the particular email address if exists with reliable domains such as Gmail, Yahoo, Outlook, etc.

In digital marketing point of view, email verification, or email validation, these refer to the process of confirming that an email address is active without sending an email.

Steps to create Email Validator in Flutter:

Adding dependency package to pubspec.yaml file:

Add the below code to pubspec.yaml file as shown

 

dependencies:
email_validator: '^1.0.0'

After adding the package run the get package method in pubspec.yaml file to import all the required files.

otherwise, it will show an error.

Import the package into the dart file:

Use the below code to import the package into the dart file. without importing it if we use the functionality of the package it will show package not found exception or error. After importing the package run the get package method to import all the dependencies to use in our dart code.

 

import 'package:email_validator/email_validator.dart';

Validating the Email:

EmailValidator is a class. has a  static method Validate(). this validate method validates the entered or specified  Email address. 

Complete Example Code for Email Validator:

import 'dart:core';
import 'package:email_validator/email_validator.dart';

void main() {
const String email = 'ifluttertutorial@gmail.com';
final bool isValid = EmailValidator.validate(email);

print('Email is valid? ' + (isValid ? 'yes' : 'no'));
}

Congratulations You Have Learned Email Validation in Flutter….!!!

If It Is Helpful Share It With Your Friends….!!!

Leave a Reply

Categories