init<E extends Enum> static method

Future<void> init<E extends Enum>({
  1. required E defaultEnv,
  2. required Map<E, String> configs,
  3. Set<E>? lockedEnvironments,
  4. bool persistSelection = true,
  5. @visibleForTesting EnvLoader? loader,
  6. @visibleForTesting EnvStore? store,
})

Initialises envify, loading all .env assets and restoring any previously persisted environment selection.

  • defaultEnv: the environment used when no persisted selection exists.
  • configs: maps each enum value to its asset path.
  • lockedEnvironments: optional set of environments from which switching is forbidden. When the active environment is in this set, switchTo throws EnvSwitchLockedException and the debug panel is rendered in a locked (non-interactive) state. Defaults to no lock.
  • persistSelection: whether the active environment is saved to and restored from SharedPreferences across sessions. When false, the app always starts from defaultEnv and switches are not written to the store. Defaults to true.

Must be awaited before calling any other Env method.

Implementation

static Future<void> init<E extends Enum>({
  required E defaultEnv,
  required Map<E, String> configs,
  Set<E>? lockedEnvironments,
  bool persistSelection = true,
  @visibleForTesting EnvLoader? loader,
  @visibleForTesting EnvStore? store,
}) async {
  await EnvManager.init<E>(
    defaultEnv: defaultEnv,
    configs: configs,
    lockedEnvironments: lockedEnvironments,
    persistSelection: persistSelection,
    loader: loader,
    store: store,
  );
}