flutter_config
2.0.2, released 3 years ago by byneapp.com
Loads .env files and exposes variables to Dart, iOS and Android code.
What it does
Reads a .env file at app startup and makes each key/value pair accessible via FlutterConfig.get. Provides a test helper to inject values without a real .env file.
AI-written summary of version 2.0.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need simple access to build‑time configuration values in Flutter code
- You want the same variables available in native iOS/Android code
- You prefer a lightweight plugin without code generation
Skip it when
- You require encrypted or obfuscated secrets in the binary
- You need a full‑featured configuration management system with remote overrides
Strengths
- Very small API, easy to use
- Works on both Dart and native platforms
- Supports testing by injecting values
Weaknesses
- Secrets are not protected – must not store sensitive data
- Only reads .env files; no runtime updates
Setup
- Kind
- Plugin (native code)
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
Add the plugin, run FlutterConfig.loadEnvVariables() before runApp; iOS requires no extra steps, Android may need Gradle 4+
import 'package:flutter_config/flutter_config.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await FlutterConfig.loadEnvVariables();
runApp(MyApp());
}
// later
var apiUrl = FlutterConfig.get('API_URL');Alternatives
Packages that do the same job and could replace flutter_config.
- dotenv
Load environment variables at runtime from a .env file.
50Compare - flutter_env_native
Makes --dart-define and --dart-define-from-file variables available to native Android and iOS platforms.
51Compare - flutter_secure_dotenv
Securely load and decrypt .env files in Flutter/Dart using AES encryption.
53Compare - cli_config
Library to read config from CLI args, env vars, and JSON/YAML files
50Compare