Overview
flutter_config is a Flutter plugin that enables seamless access to environment variables in both Dart and native code for Android and iOS. It brings 12-factor app principles to Flutter by allowing developers to manage configuration externally, improving security and flexibility across different environments like development, staging, and production. The package reads configuration from platform-specific files (e.g., info.plist on iOS, build.gradle on Android) and exposes them as constants in Dart. This helps avoid hardcoding sensitive values and simplifies deployment workflows.
Use cases
- Managing API endpoints per environment
- Storing API keys securely
- Switching between dev/staging/prod configurations
- Customizing app behavior based on environment
- Enabling feature flags via config
- Sharing config with native code
Key features
- Supports Android and iOS platforms
- Reads config from native project files
- Exposes variables to Dart and native code
- Follows 12-factor app methodology
- Easy integration via pub add
- No runtime overhead
Suitable for
- Developers using multiple environments
- Teams needing secure config management
- Apps requiring native code access to config
- Projects following 12-factor principles
- CI/CD pipelines with environment-specific settings
- Apps with dynamic feature toggles
Considerations
- Config must be set before app starts
- Sensitive data should not be committed to version control
- Requires manual setup in native projects
- Not suitable for runtime configuration changes
- Limited to static values at build time
- Needs proper documentation for team onboarding