flutter_secure_2fa 1.0.2
flutter_secure_2fa: ^1.0.2 copied to clipboard
A secure and flexible 2FA package for Flutter using TOTP. Supports SHA1/SHA256/SHA512 algorithms, variable digits, and time window verification.
Flutter Secure 2FA 🔐 #
A robust, flexible, and universal 2FA (Two-Factor Authentication) solution for Flutter applications.
flutter_secure_2fa empowers developers to implement standard TOTP (Time-Based One-Time Password) flows effortlessly. It is designed to be compatible with Google Authenticator, Authy, Microsoft Authenticator, and more.
✨ Features #
- 🔐 Universal Compatibility: Works with all major authenticator apps.
- 🛠️ Fully Configurable:
- Algorithms: Support for SHA1, SHA256, and SHA512.
- Digits: Standard 6-digit or secure 8-digit codes.
- Intervals: Custom time steps (default 30s).
- ⏱️ Clock Drift Tolerance: Built-in "Time Window" verification to handle server/client time sync issues.
- 📱 QR Code Ready: Generates standard
otpauth://URLs for easy QR code scanning. - 🐞 Developer Friendly: Detailed error logging in debug mode.
📸 Screenshots #
| Activation | Verification |
|---|---|
![]() |
![]() |
Screenshots coming soon!
📦 Installation #
Add this to your pubspec.yaml:
dependencies:
flutter_secure_2fa: ^1.0.1
🚀 Usage #
Simple Implementation #
import 'package:flutter_secure_2fa/flutter_secure_2fa.dart';
final secure2FA = FlutterSecure2FA();
// 1. Generate a Secret
String secret = secure2FA.generateSecret();
// 2. Get QR Code URL
String authUrl = secure2FA.getAuthUrl(
secret,
appName: 'My Awesome App',
accountName: '[email protected]'
);
// 3. Verify Code
bool isValid = secure2FA.verifyCode(secret, '123456');
Advanced Configuration ⚙️ #
Handle complex security requirements with ease:
bool isValid = secure2FA.verifyCode(
secret,
userInputCode,
algorithm: Secure2FAAlgorithm.sha256, // Use SHA256
digits: 8, // Expect 8 digits
interval: 60, // 60-second rotation
window: 2, // Check +/- 2 intervals (Drift tolerance)
);
🤝 Contact & Support #
This package is maintained by Hanif Uddin.
- Email: [email protected]
- GitHub: hanifuddin15
- Repo Link: flutter_secure_2fa
If you find this package useful, please give it a generic 👍 on pub.dev and a ⭐ on GitHub!

