Package selection guidance compiled from public package information, community data, and project usage.
flutter_2fa is a Flutter package that enables Two Factor Authentication (2FA) in applications using authenticator apps like Google Authenticator. It provides tools to generate and manage time-based one-time passwords (TOTP), simplifying secure user authentication. The package supports multiple platforms including Android, iOS, Web, macOS, Windows, and Linux, ensuring cross-platform consistency. With straightforward integration via the command `flutter pub add flutter_2fa`, developers can enhance app security with minimal setup. It's ideal for apps requiring strong user verification without relying solely on passwords.
Use cases
Secure login systems
Two-factor authentication for user accounts
Enhancing app security with TOTP
Integration with authenticator apps
User identity verification
Multi-factor authentication workflows
Key features
TOTP code generation
Cross-platform support
Easy integration with Flutter
Supports popular authenticator apps
Secure token handling
Real-time time synchronization
Suitable for
Apps requiring enhanced security
Developers building secure authentication flows
Mobile and web applications with user logins
Projects using 2FA standards like RFC 6238
Teams wanting quick 2FA implementation
Considerations
Requires user setup of authenticator app
Depends on system clock accuracy
No built-in backup or recovery mechanism
Limited customization for advanced 2FA scenarios
Not suitable for offline-only environments
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
Flutter 2FA
🔐 A Flutter package to add secure Two-Factor Authentication (2FA) via time-based one-time passwords (TOTP) to any Flutter application with ease.
📸 Screenshots
✨ Features (v1.0.5 Upgrade)
Quick Setup: Generates a standard cryptographically secure TOTP secret key compatible with Google Authenticator, Microsoft Authenticator, Authy, etc.
QR Code Generation: Integrated visual setup flow using dynamic QR codes.
Copy-to-Clipboard: Fallback configuration flow allowing users to copy the raw setup key manually.
Secure OTP Verification: Standard input interface using high-quality pin inputs (pinput integration).
🎨 Custom UI Themes: Override background colors, text colors, AppBars, button styles, and PIN input decorations to match your app's design system.
🔒 Secure Storage: Optional encrypted storage backend via flutter_secure_storage to secure secret keys and recovery codes.
🛡️ Biometric Authentication: Quick local unlock (Face ID / Touch ID / Fingerprint) via local_auth integration.
🧩 Backup Recovery Codes: Generates 10 static recovery codes during activation. Displayed under a space-saving collapsible accordion. Users can use these codes as a login fallback.
[!NOTE]
To support newer platform libraries and Dart 3.x, transitive dependency upgrades have been applied (specifically upgrading internal Windows helpers which removes deprecated win32 3.1.3 conflicts).
⚙️ Android Toolchain Requirements
To compile successfully with newer dependency versions (e.g. Kotlin 2.x and Java 21), make sure your Android project files are configured as follows:
Gradle Wrapper: Version 8.14.0 or higher (gradle-wrapper.properties).
Android Gradle Plugin (AGP): Version 8.11.1 or higher (settings.gradle).
Kotlin: Version 2.2.20 or higher (settings.gradle).
Compile SDK: Version 34 or higher (app/build.gradle).