EnvInterface class abstract interface

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 .env files 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, or null if not found.
getBool(String key, {bool defaultValue = false}) bool
Returns the value of the key as a boolean.
getDouble(String key, {double defaultValue = 0.0}) double
Returns the value of the key as a double.
getInt(String key, {int defaultValue = 0}) int
Returns the value of the key as 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 key if found, otherwise returns defaultValue.
getOrFail(String key) String
Returns the value of the key or throws an exception if not found.
has(String key) bool
Checks if a key exists in the current environment.
loadFromFile(String path) → void
Loads variables from a .env file located at path.
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 key to the given value.
toString() String
A string representation of this object.
inherited
validateRequired(List<String> requiredKeys) List<String>
Ensures that all requiredKeys exist in the environment.

Operators

operator ==(Object other) bool
The equality operator.
inherited