搜尋套件、儲存庫與 APP 分類

套件詳情v3.0.0

email_validator

一個簡單(但正確)的 Dart 類,用於驗證電子郵件地址

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
85萬
喜歡數
1230
Pub 分數
160

安裝套件

flutter pub add email_validator

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

email_validator 套件提供了一個簡單且精確的 Dart 類別,用於根據標準 RFC 5322 規範驗證電子郵件位址。它確保在多個平台(包括行動裝置、網頁和桌面)上可靠地檢查電子郵件格式。該套件輕量級,易於整合,適用於 Flutter 應用程式中的表單驗證。它支援基本與進階驗證情境,無需外部相依性。

適用情境

  • 表單輸入驗證
  • 使用者註冊流程
  • 登入畫面電子信箱驗證
  • 資料完整性驗證
  • 即時電子郵件反饋

主要特色

  • 符合 RFC 5322 的驗證
  • 跨平台支援
  • 簡單的 API,具備明確的錯誤處理
  • 輕量且無依賴
  • 支援國際化電子郵件位址

適合對象

  • 需要電子郵件驗證的Flutter應用
  • 開發人員優先考慮正確性而非速度
  • 需要嚴格電子郵件格式規則的應用程式
  • Web和移動應用中的前端驗證
  • 外部依賴最少的專案

使用建議

  • 不驗證電子郵件是否實際存在
  • 未包含伺服器端驗證
  • 可能會拒絕一些有效但不常見的電子郵件格式
  • 僅限語法檢查,不包含交付確認
  • 不適合高容量電子郵件處理

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Email Validator.dart

CI pub package

A simple Dart class for validating email addresses without using RegEx. Can also be used to validate emails within Flutter apps (see Flutter email validation).

NB: This library only validates the syntax of the email, not by looking up domain or whether an email actually exists.

Featured in:

  1. How To Validate Emails in Flutter by https://github.com/lucianojung
  2. Flutter Tutorial - Email Validation In 7 Minutes by https://github.com/JohannesMilke
  3. Flutter Tutorial - Email Validation | Package of the week by https://github.com/Dhanraj-FlutterDev

Found in several big libraries and apps:

  1. Google Firebase
  2. Flutter GenUI
  3. Supabase - Flutter auth UI
  4. TubeCards - The world’s best flashcard platform
  5. Serverpod - Serverpod is a next-generation app and web server, explicitly built for Flutter
  6. Several other packages on pub.dev

And many more!

Installation

1. Depend on it

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

dependencies:
    email_validator: '^3.0.6'
2. Install it

You can install packages from the command line:

$ dart 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));
}

Tips

You can also use this repo as a template for creating Dart packages, just clone the repo and start hacking :)

所屬分類

原始碼儲存庫

使用此套件的專案

所在榜單