๐ŸŒฟ envified

pub package License: MIT Dart CI

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.

envified Floating Button      envified Debug Panel


โœจ Why You'll Love It

  • โšก๏ธ Switch in Seconds: Swap from dev to prod in 0.2 seconds. No compilation, no coffee breaks.
  • ๐Ÿ”’ The "Safety First" Lock: We lock your prod environment 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:

  1. 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.
  2. Production Lock: By setting allowProdSwitch: false, you ensure that no one (not even you!) can accidentally point your production app to a dev server.
  3. 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!

  1. Fork it: Click that button at the top right.
  2. Branch it: git checkout -b feature/my-amazing-idea.
  3. Code it: Make your changes (and add tests, or the lint gods will be angry).
  4. Commit it: git commit -m 'Add some magic'.
  5. Push it: git push origin feature/my-amazing-idea.
  6. 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:

  1. Head over to the Issue Tracker.
  2. Search if someone else already complained about it.
  3. 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.