simple_totp_auth 0.0.2
simple_totp_auth: ^0.0.2 copied to clipboard
A Flutter package to generate and verify TOTP codes with QR setup widget. Works on all platforms.
๐ simple_totp_auth #
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!
Demo Screenshots #
โจ Features #
- ๐ 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
๐ Installation #
dependencies:
simple_totp_auth: ^0.0.2
๐งช Usage #
๐ Generate a Secure Secret Key #
final secret = TOTP.generateSecret();
๐งฎ Generate a TOTP Code (Valid for 30 seconds) #
final totp = TOTP(secret: secret);
final code = totp.now();
print("Code: $code");
โ Verify a Code #
final totp = TOTP(secret: secret);
final code = totp.now();
print("Code: $code");
๐ก Generate QR-Compatible URI #
final uri = totp.generateOTPAuthURI(
issuer: "MyApp",
account: "user@example.com",
);
print(uri);
๐ท Display the QR Code in Your App #
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,
)
๐ Copy Secret to Clipboard (with feedback) #
final result = await TOTPUtils.copyToClipboard(secret);
print(result); // "Success" or error message
๐ฆ Platform Support #
Platform Support โ Android Yes โ iOS Yes โ Web Yes โ Windows Yes โ macOS Yes โ Linux Yes Works across all 6 major platforms with no native plugins!
โ Support the Developer #
If you found this package helpful, consider buying me a coffee:
Thanks for using simple_totp_auth
โค๏ธ