Contract for accessing and managing environment variables.
This interface abstracts access to .env files or environment
variables loaded into memory, providing helpers for typed access.
Example usage:
final port = env.getInt('PORT', defaultValue: 3000);
final debug = env.getBool('APP_DEBUG', defaultValue: false);
- Implementers
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
-
loadedFiles
→ List<
String> -
A list of
.envfiles that have been loaded.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
all(
) → Map< String, String> - Returns a map of all loaded environment variables.
-
clear(
) → void - Clears all currently loaded environment variables from memory.
-
get(
String key) → String? -
Returns the raw string value for the given
key, ornullif not found. -
getBool(
String key, {bool defaultValue = false}) → bool -
Returns the value of the
keyas a boolean. -
getDouble(
String key, {double defaultValue = 0.0}) → double -
Returns the value of the
keyas a double. -
getInt(
String key, {int defaultValue = 0}) → int -
Returns the value of the
keyas an integer. -
getList(
String key, {String separator = ',', List< String> defaultValue = const []}) → List<String> -
Returns a list of strings split by
separator. -
getOrDefault(
String key, String defaultValue) → String -
Returns the value of the
keyif found, otherwise returnsdefaultValue. -
getOrFail(
String key) → String -
Returns the value of the
keyor throws an exception if not found. -
has(
String key) → bool -
Checks if a
keyexists in the current environment. -
loadFromFile(
String path) → void -
Loads variables from a
.envfile located atpath. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
set(
String key, String value) → void -
Sets a runtime environment variable
keyto the givenvalue. -
toString(
) → String -
A string representation of this object.
inherited
-
validateRequired(
List< String> requiredKeys) → List<String> -
Ensures that all
requiredKeysexist in the environment.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited