A lightweight Flutter package for generating, verifying, and sharing Time-based One-Time Passwords (TOTP) using QR codes — perfect for adding secure 2FA (Two-Factor Authentication) to any app.
✅ Compatible with Google Authenticator, Microsoft Authenticator, Authy, and more!
- 🔑 Generate secure Base32 TOTP secrets
- 🕒 Create & verify 6-digit TOTP codes (RFC 6238)
- 📱 Generate otpauth:// URIs
- 📷 Display QR codes for Authenticator setup
- 📋 Copy secrets to clipboard (cross-platform support)
- 🧩 Flutter Widget for QR with custom size, color, and logo
dependencies:
simple_totp_auth: ^0.0.2final secret = TOTP.generateSecret();
final totp = TOTP(secret: secret);
final code = totp.now();
print("Code: $code");
final totp = TOTP(secret: secret);
final code = totp.now();
print("Code: $code");
final uri = totp.generateOTPAuthURI(
issuer: "MyApp",
account: "user@example.com",
);
print(uri);
TOTPQrWidget(
secret: secret,
issuer: 'MyApp',
accountName: 'user@example.com',
logoType: LogoType.asset, // Choose asset or network
logoPath: 'images/logo.png', // Path to the asset or URL for network image
width: 200,
height: 200,
color: Colors.white,
radiusColor: Colors.blue,
radiusWidth: 2,
radius: 16,
padding: 8,
margin: 8,
)
final result = await TOTPUtils.copyToClipboard(secret);
print(result); // "Success" or error message
Platform Support ✅ Android Yes ✅ iOS Yes ✅ Web Yes ✅ Windows Yes ✅ macOS Yes ✅ Linux Yes Works across all 6 major platforms with no native plugins!
If you found this package helpful, consider buying me a coffee:
Thanks for using simple_totp_auth ❤️


