The primary public interface for envify.
Minimal setup
await Env.init(
defaultEnv: Environment.production,
configs: {
Environment.dev: 'assets/env/.env.dev',
Environment.staging: 'assets/env/.env.staging',
Environment.production: 'assets/env/.env.production',
},
);
Accessing values
final baseUrl = Env.get('BASE_URL');
final timeout = Env.getInt('TIMEOUT');
final darkMode = Env.getBool('DARK_MODE');
Switching at runtime
await Env.switchTo(Environment.staging);
All methods delegate to the EnvManager singleton; they throw
EnvNotInitializedException if called before init.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- current → Enum
-
The currently active environment enum value.
no setter
-
currentEnvData
→ Map<
String, String> -
All key/value pairs loaded for the currently active environment.
no setter
- currentNotifier → ValueNotifier
-
A ValueNotifier that emits the active environment whenever it changes.
no setter
- isLocked → bool
-
Whether the currently active environment is locked.
no setter
Static Methods
-
get(
String key) → String -
Returns the raw String value for
keyin the active environment. -
getBool(
String key) → bool -
Returns the value for
keyparsed as a bool. -
getDouble(
String key) → double -
Returns the value for
keyparsed as a double. -
getInt(
String key) → int -
Returns the value for
keyparsed as an int. -
getOrElse(
String key, String fallback) → String -
Returns the value for
key, orfallbackif the key is absent. -
init<
E extends Enum> ({required E defaultEnv, required Map< E, String> configs, Set<E> ? lockedEnvironments, EnvLoader? loader, EnvStore? store}) → Future<void> -
Initialises envify, loading all
.envassets and restoring any previously persisted environment selection. -
switchTo(
Enum env) → Future< void> -
Switches the active environment to
envand persists the selection.