envx library
Layered configuration and typed environment selection for Dart and Flutter.
Use EnvxBuilder for providers or Environment for environment factories.
Native filesystem/process providers are available in envx_io.dart.
Classes
- ConfigSource
- An asynchronous provider of JSON-compatible configuration values.
- ConfigValues
- Immutable configuration with case-sensitive, dot-separated path access.
- Environment
- Factory for creating typed or non-typed EnvironmentInstances.
-
EnvironmentInstance<
K, C> - Base environment wrapper used by both typed and non-typed variants.
- EnvxBuilder
- Loads ordered sources into immutable values or a validated application model.
- EnvxConstants
- Constants used by the library. Keep magic strings out of the code.
- MemoryConfigSource
- Immutable defaults or explicit overrides available on every platform.
Functions
-
aliasesResolver<
E extends Enum> (Map< E, List< aliases, {bool caseInsensitive = true, bool allowEnumName = true, bool strictCollisions = false}) → EnvResolver<String> >E> -
Set
strictCollisions: trueto reject aliases assigned to different values. By default, the last assignment wins for 1.x compatibility. -
nestEnvironmentValues(
Map< String, String> values, {String prefix = '', String separator = '__'}) → Map<String, Object?> - Maps flat environment strings to nested, case-sensitive configuration.
-
parseDotEnv(
String text) → Map< String, String> - Parses dotenv assignments into strings without interpolation or evaluation.
-
parseJsonConfig(
String text) → Map< String, Object?> - Parses a JSON object, rejecting arrays, scalars, and invalid JSON.
-
tokenResolver<
E extends Enum> (Map< String, E> tokens, {bool caseInsensitive = true, bool strictCollisions = false}) → EnvResolver<E> -
Set
strictCollisions: trueto reject conflicting normalized tokens. By default, the last assignment wins for 1.x compatibility.
Typedefs
-
EnvResolver<
K> = K? Function(String input) - Signature for functions that map a raw environment string to a typed key.
Exceptions / Errors
- ConfigBindingException
- A caller's model binder failed.
- ConfigException
- A configuration failure with a safe, value-free diagnostic message.
- ConfigMissingException
- A required path was absent or contained null.
- ConfigParseException
- Configuration text has invalid syntax or a non-object JSON root.
- ConfigSourceException
- A required configuration source could not be read.
- ConfigTypeException
- A configuration value could not be converted to the requested type.
- ConfigValidationException
- Configuration did not satisfy application validation rules.