๐ฟ envified
Stop Rebuilding. Start Switching. ๐
Tired of waiting for Flutter to rebuild just to check your app against staging? Still hard-coding base URLs like it's 2015?
envified is the runtime brain for your Flutter app. Load your .env files, swap environments on the fly, and override your API URLsโall without a single hot reload.
๐ธ The "Look Ma, No Rebuilds!" UI
envified ships with a premium, dark-luxury debug overlay. It stays invisible in production but pops up when you need it most.
โจ Why You'll Love It
- โก๏ธ Switch in Seconds: Swap from
devtoprodin 0.2 seconds. No compilation, no coffee breaks. - ๐ The "Safety First" Lock: We lock your
prodenvironment by default. No accidental data deletions here. - ๐งช API Mad Scientist Mode: Override your base URL at runtime. Test against that local tunnel or a specific PR branch instantly.
- ๐พ Memory Like an Elephant: Your selections and URL overrides persist across app restarts.
- โ๏ธ Ghost in the Machine: The debug UI is stripped out completely in release builds. Zero overhead.
๐ฆ What's Under the Hood? (Dependencies)
We keep it lean and mean on security. envified only relies on:
flutter_secure_storage: To make sure your environment choices and sensitive URL overrides are encrypted and stored in the Keychain (iOS) or Keystore (Android). ๐flutter: Because, well, it's a Flutter package. ๐ฆ
๐ Quick Start (30 Seconds)
1. Grab the Package
dependencies:
envified: ^1.0.0
2. Toss in your .env files
Create your .env files and tell Flutter where they are in pubspec.yaml:
flutter:
assets:
- assets/env/.env # Shared defaults
- assets/env/.env.dev # Dev overrides
- assets/env/.env.staging # Staging overrides
- assets/env/.env.prod # Prod overrides
3. Light the Fuse
Initialize before runApp():
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await EnvConfigService.instance.init(
defaultEnv: Env.dev,
allowProdSwitch: false, // Lock prod for safety!
);
runApp(const MyApp());
}
๐ช The Magic Sauce
Injecting the Overlay
Wrap your app using the builder pattern. This puts the ๐ฟ button on top of every screen.
MaterialApp(
builder: (context, child) => EnvifiedOverlay(
service: EnvConfigService.instance,
enabled: kDebugMode, // Only show in debug!
child: child ?? const SizedBox.shrink(),
),
home: const MyAwesomeApp(),
)
Grabbing Values
It's as simple as reading a variable:
final config = EnvConfigService.instance.current.value;
print(config.baseUrl); // "https://api.example.com"
print(config.values['API_KEY']); // "shhh_its_a_secret"
๐ Enterprise-Grade Security
We don't take security lightly. Unlike other packages that use plain-text storage:
- Encrypted Persistence: Every environment switch and URL override is persisted using AES encryption on Android and the Secure Keychain on iOS via
flutter_secure_storage. - Production Lock: By setting
allowProdSwitch: false, you ensure that no one (not even you!) can accidentally point your production app to a dev server. - Zero-Leak Release: The debug ๐ฟ button and panel code are completely optimized out in release builds.
๐ Security: The "Prod Lock"
We've all been there. You accidentally hit a "Delete All" button while thinking you were in dev. envified stops the nightmare:
- Switching out of Prod? Forbidden. ๐ซ
- Overriding a Prod URL? Not on our watch. ๐ฎโโ๏ธ
To unlock, you must explicitly change your initialization code.
๐ค Contributing (Join the Cult! ๐ฟ)
Got an idea to make envified even more magical? We love PRs!
- Fork it: Click that button at the top right.
- Branch it:
git checkout -b feature/my-amazing-idea. - Code it: Make your changes (and add tests, or the lint gods will be angry).
- Commit it:
git commit -m 'Add some magic'. - Push it:
git push origin feature/my-amazing-idea. - Open a PR: And wait for the applause. ๐
๐ Found a Bug? (The "Oh No!" Section)
If something isn't working right, or you have a feature request that just can't wait:
- Head over to the Issue Tracker.
- Search if someone else already complained about it.
- If not, open a new issue. Be descriptive! "It's broken" helps no one. "The leaf icon turned into a potato on iPhone 4" is much better.
๐ License
MIT. Go build something amazing. ๐
Libraries
- envified
- envified โ Runtime environment switching for Flutter.