EnvManager<E extends Enum> class
Central coordinator for environment loading, switching, and persistence.
EnvManager is a controlled singleton. Access it via EnvManager.instance after calling EnvManager.init.
Type parameter E must be the user-defined enum that identifies
environments (e.g. Environment).
Properties
-
allValues
→ List<
E> -
All registered environment values, in declaration order.
no setter
- current → E
-
The currently active environment.
no setter
-
currentEnvData
→ Map<
String, String> -
All key/value pairs loaded for the current environment.
no setter
-
currentNotifier
→ ValueNotifier<
E> -
A ValueNotifier that broadcasts the currently active
Ewhenever the environment is switched. Useful for reactive UI updates.final - hashCode → int
-
The hash code for this object.
no setterinherited
- isCurrentLocked → bool
-
Whether the currently active environment is locked.
no setter
- persistSelection → bool
-
Whether the active environment is saved to and restored from
SharedPreferencesacross sessions.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
get(
String key) → String -
Returns the raw string value for
keyin the current environment. -
getBool(
String key) → bool -
Returns the value for
keyas a bool. -
getDouble(
String key) → double -
Returns the value for
keyas a double. -
getInt(
String key) → int -
Returns the value for
keyas an int. -
getOrElse(
String key, String fallback) → String -
Returns the raw string value for
key, orfallbackif absent. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setPersistSelection(
bool persist) → Future< void> - Changes the persist mode at runtime.
-
switchTo(
E env) → Future< void> -
Switches the active environment to
env. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- instance → EnvManager
-
The active EnvManager singleton.
no setter
Static Methods
-
init<
E extends Enum> ({required E defaultEnv, required Map< E, String> configs, Set<E> ? lockedEnvironments, bool persistSelection = true, EnvLoader? loader, EnvStore? store}) → Future<EnvManager< E> > -
Initialises the singleton with
defaultEnvand theconfigsmap. -
instanceOf<
E extends Enum> () → EnvManager< E> -
Typed convenience accessor — returns this cast to
EnvManager<E>. -
reset(
) → void - Resets the singleton. Intended for testing only.