email_validator 1.0.0

Email validator Build status

A simple (but correct) Dart class for validating email addresses.

Installation #

Dart requires the latest version of Dart. You can download the latest and greatest here.

1. Depend on it #

Add this to your package's pubspec.yaml file:

dependencies:
    email_validator: '^1.0.0'

2. Install it #

You can install packages from the command line:

$ pub get
..

Alternatively, your editor might support pub. Check the docs for your editor to learn more.

3. Import it #

Now in your Dart code, you can use:

import 'package:email_validator/email_validator.dart';

Usage #

Read the unit tests under test, or see code example below:

void main() {

    var email = "fredrik@gmail.com";

    assert(EmailValidator.validate(email) == true);

}

1.0.0 #

  • EmailValidator.Validate() is now, by Dart convention, EmailValidator.validate().

0.1.6 #

  • Cleaned up code a bit, no API changes.

0.1.5 #

  • Cleaned up code a bit, no API changes.

0.1.4 #

  • Now supports a broader variety of Dart sdk versions

0.1.0 #

  • Validate emails through a static method EmailValidator.validate().

example/example.dart

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

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

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

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  email_validator: ^1.0.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:email_validator/email_validator.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
94
Health:
Code health derived from static analysis. [more]
85
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
93
Learn more about scoring.

We analyzed this package on Jul 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:email_validator/email_validator.dart.

Health suggestions

Fix lib/email_validator.dart. (-14.82 points)

Analysis of lib/email_validator.dart reported 32 hints, including:

line 85 col 7: DO use curly braces for all flow control structures.

line 98 col 7: DO use curly braces for all flow control structures.

line 106 col 7: DO use curly braces for all flow control structures.

line 113 col 11: DO use curly braces for all flow control structures.

line 116 col 11: DO use curly braces for all flow control structures.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.24.0 <3.0.0
Dev dependencies
test ^1.3.0

Admin