flutter_secure_dotenv
2.0.0, released 9 months ago by mfazrinizar.com
Securely load and decrypt .env files in Flutter/Dart using AES encryption.
What it does
It generates Dart classes from encrypted .env files, providing typed access to environment variables. The package handles key/IV management and decryption at runtime.
AI-written summary of version 2.0.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to keep secrets out of plain text in your repo
- You want compile‑time type safety for env variables
- You are building a Flutter or Dart app that requires secure config
Skip it when
- You need secrets that must never be in the binary (use server‑side key fetch)
- You prefer a simple, non‑encrypted dotenv solution
Strengths
- Strong encryption with AES‑CBC and key/IV handling
- Zero‑runtime dependency on external services
- Full code‑gen support for typed env classes
- Comprehensive security guidance in SECURITY.md
Weaknesses
- Key must be stored in binary unless fetched from server
- Requires build_runner for code generation
- No runtime key rotation support
Setup
- Kind
- Pure Dart
- Effort
- Medium
- Code generation
- Yes (build_runner)
- Direct dependencies
- 1
Add dependency, dev_dependencies (build_runner, flutter_secure_dotenv_generator), run build_runner with --define to generate key file, copy key to git‑ignored env.dart, delete key file, then use generated Env class.
```dart
import 'package:flutter_secure_dotenv/flutter_secure_dotenv.dart';
final env = Env.create();
print(env.apiKey);
```Alternatives
Packages that do the same job and could replace flutter_secure_dotenv.
- aes256
AES‑256‑GCM encryption/decryption with PBKDF2‑SHA256 key derivation.
62Compare - pqforge
Pure-Dart post-quantum cryptography for ML-KEM, ML-DSA, SLH-DSA, and HPKE.
71Compare - cryptography_plus
Cryptographic algorithms for encryption, signatures, key agreement, and hashing across platforms.
68Compare - cryptography
Cross‑platform cryptographic algorithms for Dart and Flutter.
67Compare
Works with
Packages commonly used together with flutter_secure_dotenv: ones it builds on, ones built on it, and its own family.