envified 2.0.0
envified: ^2.0.0 copied to clipboard
Runtime environment switching for Flutter. Load .env files, switch dev/staging/prod/custom at runtime, override base URLs, and lock production config — no rebuild required.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
2.0.0 - 2026-05-07 #
Major Release 🚀 — Eight Improvements #
1. Tamper Detection (verifyIntegrity)
EnvFileParser.verifyIntegrity()computes a SHA-256 hash of each.env*file on first load and stores it influtter_secure_storage.- Subsequent loads recompute and compare — a hash mismatch throws the new
EnvifiedTamperException. - Opt-in via
EnvConfigService.init(verifyIntegrity: true).
2. Access Token Gate (EnvGate)
- New
EnvGateclass exported from the public API. - Supports PIN-only, biometric-only, or either-method authentication.
- Pass
gate: EnvGate(pin: '1234')toEnvifiedOverlayto require auth before revealing the debug panel. - PIN dialog implemented inline (no third-party packages) with 4 obscured digit fields.
- Auto-clears authentication state when the app is backgrounded.
3. Typed Get Helpers
getBool(key)— accepts'true','1','yes'(case-insensitive).getInt(key)— wrapsint.tryParse.getDouble(key)— wrapsdouble.tryParse.getUri(key)— wrapsUri.tryParse, returnsnullon failure.getList(key, {separator})— splits and trims CSV values.
4. Lifecycle Hooks
onBeforeSwitch: Future<void> Function(Env from, Env to)?— awaited beforeswitchTo()changes the active env.onAfterSwitch: void Function(EnvConfig config)?— called afterswitchTo()andsetBaseUrl().- Both hooks are supplied to
EnvConfigService.init(). - New
EnvNameextension onEnvwithlongLabel(e.g."Development","Production").
5. URL History Picker
EnvStorage.saveUrlToHistory()/loadUrlHistory()— persists up to 5 recent URLs (deduped, newest-first) in secure storage.EnvConfigService.urlHistoryexposes the list.EnvDebugPanelshows a "Recent" row of tappableActionChipwidgets below the URL override field.- Tapping a chip applies the URL and updates the text field.
6. Env Status Badge (EnvStatusBadge)
- New standalone
EnvStatusBadgewidget. - Colour-coded per environment (blue / orange / red / purple).
- Pulsing opacity animation (1.0 ↔ 0.7, 1.5 s) when
isBaseUrlOverriddenistrue. - Respects
MediaQuery.disableAnimations(system reduced-motion preference). - Configurable
alignmentandmargin.
7. Gesture Trigger Config (EnvTrigger)
- New
sealed class EnvTriggerreplacing the hard-coded FAB tap. EnvTrigger.tap(count: 7)— N rapid taps within 800 ms (default).EnvTrigger.shake(threshold: 15.0)— accelerometer shake viasensors_plus, 2 s debounce.EnvTrigger.edgeSwipe(edgeWidth: 20)— right-edge inward swipe viaListener.- Pass
trigger:toEnvifiedOverlay. - Added
showFab: falseoption toEnvifiedOverlayto enable a true "stealth mode" where the floating 🌿 button is hidden and the trigger is the exclusive way to access the panel. - Fixed a bug where taps on the panel or FAB incorrectly advanced the hidden tap count, ensuring triggers accurately reflect gesture counts.
8. Audit Log
AuditEntrymodel (exported) withtimestamp,action,fromEnv,toEnv,url.- Every mutation (
switchTo,setBaseUrl,clearBaseUrlOverride,reset) appends an entry toflutter_secure_storage. - Log is capped at 50 entries; oldest are dropped.
EnvConfigService.auditLogreturns the full list.EnvDebugPanelshows an expandable "Activity log (N entries)" tile with the last 10 entries.
Auto-lock on Background
EnvifiedOverlayregisters anAppLifecycleListenerononHide/onPause.- The panel closes and authentication is cleared whenever the app moves to background.
New Dependencies #
local_auth: ^2.2.0sensors_plus: ^5.0.0crypto: ^3.0.0
Breaking Changes #
Env.labelnow returns short form ('Dev','Staging','Prod','Custom'). Use the newEnv.longLabel(viaEnvNameextension) for full names.EnvStorage.clear()now also deletes URL history and audit log keys.
Migration Guide from 1.0.0 #
// Before
await EnvConfigService.instance.init(defaultEnv: Env.dev);
// After (all new params are optional with safe defaults)
await EnvConfigService.instance.init(
defaultEnv: Env.dev,
verifyIntegrity: false, // opt-in
onBeforeSwitch: null, // optional
onAfterSwitch: null, // optional
allowedUrls: null, // optional
);
// EnvifiedOverlay — new optional params
EnvifiedOverlay(
service: EnvConfigService.instance,
enabled: kDebugMode,
gate: null, // optional
trigger: const EnvTrigger.tap(count: 7), // default unchanged
showFab: true, // optional (set to false for stealth mode)
child: child!,
)
1.0.0 - 2026-05-06 #
Initial Stable Release 🚀 #
- Runtime Environment Switching — Seamlessly swap between
dev,staging,prod, andcustomwithout rebuilding your app. - Enterprise-Grade Security — Fully encrypted persistence layer using
flutter_secure_storage. Choices and overrides are stored in Keychain/Keystore. - Production Lock — Prevent accidental environment switches or URL overrides in production builds.
- API URL Overrides — Dynamically point your app to any backend URL at runtime (perfect for local testing or PR reviews).
- Premium Debug UI — Built-in, horizontally scrollable action chip panel and floating action button that only appears in debug mode.
- Zero-Overhead — Debug components are completely optimized out in release builds.
- Bulletproof Reliability — Comprehensive unit test suite covering parsing, models, storage, and service logic.
0.1.2 - 2026-05-06 #
- Security upgrade to encrypted storage.
- Storage injection for unit testing.
0.1.0 - 2026-05-06 #
- Initial beta release.