Aus öffentlichen Paketdaten erstellte Orientierung.
Ein leichtgewichtiger Flutter-Paket zur Übermittlung und Überprüfung von E-Mail-basierten Einmalpasswörtern (OTP), um die Benutzerauthentifizierung zu vereinfachen. Es ermöglicht eine schnelle Integration von E-Mail-OTP-Flüssen mit minimaler Konfiguration und unterstützt mehrere Plattformen wie Android, iOS, macOS, Windows und Linux. Das Paket verwaltet die Backend-Kommunikation für die Generierung und Validierung von OTP und verringert die Entwicklungszeit für sichere Anmelde-Systeme. Ideal für Apps, die sichere, passwortlose Anmeldung oder Kontoverifizierung erfordern.
Anwendungsfälle
Passwortloser Login
Kontoverifizierung
Sichere Benutzerauthentifizierung
Zwei-Faktor-Authentifizierung
Zurücksetzen vergessener Passwörter
Hauptmerkmale
Einfache OTP-Erzeugung
E-Mail-basierte Überprüfung
Plattformübergreifende Unterstützung
Minimale Boilerplate-Code
Einfache Integration mit Firebase oder benutzerdefinierten Backends
Geeignet für
Entwickler, die sichere Authentifizierung erstellen
Apps, die schnelle OTP-Workflows benötigen
Projekte, die E-Mail als primäre Identität verwenden
Startups, die schnelle Funktionsbereitstellung priorisieren
Teams, die komplexe Authentifizierungsinfrastruktur vermeiden
Hinweise
Benötigt einen Backend-Service zur OTP-Verwaltung
Abhängig von zuverlässiger E-Mail-Zustellung
Nicht geeignet für hochvolumige transaktionale E-Mails
In der Produktion könnte eine Rate-Limiting-Einstellung erforderlich sein
Die Benutzererfahrung hängt von der Zuverlässigkeit des E-Mail-Anbieters ab
Original-README
Originaler README-Schnappschuss aus dem verknüpften Quell-Repository. Aktuelle Inhalte finden Sie im Repository.
Email OTP is a Flutter package designed to simplify email authentication using one-time passwords (OTPs). With Email OTP, you can effortlessly generate OTPs and send them to users' email addresses, ensuring secure identity verification. This package offers an efficient and secure method for incorporating email-based OTP authentication into your Flutter applications.
emailPort: The port number used by the SMTP server. Supported values include:
EmailPort.port25
EmailPort.port465
EmailPort.port587
EmailPort.port1025 (For MailHog/Local Testing)
secureType: The type of security used by the SMTP server. Supported values include:
SecureType.none
SecureType.tls
SecureType.ssl
username: The username for your SMTP server account.
password: The password for your SMTP server account.
By configuring these parameters, you can ensure that your application is able to send OTP emails securely and efficiently.
Themes
Theme
Theme Preview
EmailTheme.v1
EmailTheme.v2
EmailTheme.v3
EmailTheme.v4
EmailTheme.v5
EmailTheme.v6
EmailTheme.v7
EmailTheme.v8
EmailTheme.v9
EmailTheme.v10
Template (Optional)
You can also customize the email 🌐 template used to send the OTP. Use the setTemplate method to provide your own HTML template.
voidmain() {
EmailOTP.config();
EmailOTP.setTemplate(
template: '''
<div style="background-color: #f4f4f4; padding: 20px; font-family: Arial, sans-serif;">
<div style="background-color: #fff; padding: 20px; border-radius: 10px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);">
<h1 style="color: #333;">{{appName}}</h1>
<p style="color: #333;">Your OTP is <strong>{{otp}}</strong></p>
<p style="color: #333;">This OTP is valid for 5 minutes.</p>
<p style="color: #333;">Thank you for using our service.</p>
</div>
</div>
''',
);
}
Parameters
template: A string containing the HTML content of your custom email template. Use placeholders such as {{appName}} and {{otp}} to dynamically insert the application name and OTP respectively.
By configuring these parameters and using a custom template, you can ensure that your OTP emails are tailored to match your application's branding and style.
Sending OTP
To 📧 send an 🔐 OTP to a user's email address, use the sendOTP method. This method takes the recipient's email address as a parameter.
bool isSent = awaitEmailOTP.sendOTP(email: emailController.text);
if (!isSent) {
print(EmailOTP.lastError); // Prints specific error (e.g. SMTP Auth failed)
}
Parameters
email: The recipient's email address where the OTP will be sent.
Resending OTP
If a user requests a new OTP because they didn't receive the first one, you can use resendOTP instead of generating a new one. This will re-send the existing valid OTP. If it has already expired, a new one will automatically be generated.
EmailOTP.resendOTP(email: emailController.text);
Verifying OTP
To verify an 🔐 OTP entered by the user, use the verifyOTP method. This method takes the OTP entered by the user as a parameter and returns a boolean indicating whether the OTP is correct.
EmailOTP.verifyOTP(otp: otpController.text)
Parameters
otp: The OTP entered by the user.
Get OTP
This code will print the OTP generated by the getOTP() method.
print(EmailOTP.getOTP());
Is Expired
This method will helps you to validate your otp expiry time.