ConfigurationManager class final

A configuration that is both a builder and a live Configuration.

ConfigurationManager is the recommended entry point for applications that need to add or remove providers at runtime without rebuilding the entire configuration. Each call to add immediately builds and loads the corresponding provider, making the new values available through the same Configuration reference.

This is the Dart equivalent of .NET 6's ConfigurationManager.

final manager = ConfigurationManager()
  ..addInMemory({'app:name': 'Orders'})
  ..addJsonFile('appsettings.json')
  ..addEnvironmentVariables(prefix: 'APP_');

// Access values immediately — no separate build() call needed.
final host = manager['database:host'];

// Add providers at runtime:
manager.addInMemory({'feature:darkMode': 'true'});
final dark = manager['feature:darkMode']; // 'true'
Implemented types

Constructors

ConfigurationManager()
Creates a ConfigurationManager with no initial providers.

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

add(ConfigurationSource source) ConfigurationManager
Adds a ConfigurationSource and immediately loads its provider.
addEnvironmentVariables({String prefix = ''}) ConfigurationManager
Adds an EnvironmentConfigurationSource.
addInMemory(Map<String, String?> initialData) ConfigurationManager
Adds key-value pairs from an in-memory Map<String, String?>.
addJsonFile(String filePath, {bool optional = false, bool reloadOnChange = false}) ConfigurationManager
Adds a JsonFileConfigurationSource.
addJsonString(String jsonContent) ConfigurationManager
Adds a JsonStringConfigurationSource.
addMap(Map<String, dynamic> map) ConfigurationManager
Adds a generic nested Map<String, dynamic> — values are flattened.
buildSnapshot() ConfigurationRoot
Builds a static ConfigurationRoot snapshot from the current providers.
getChildren() Iterable<ConfigurationSection>
Returns all direct child sections of this configuration node.
override
getReloadToken() ChangeToken
Returns a ChangeToken that fires whenever any provider reloads.
getRequired(String key) String
Returns the value at key, throwing StateError when absent or null.
override
getSection(String key) ConfigurationSection
Returns a ConfigurationSection rooted at key.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reload() → void
Forces all providers to reload synchronously.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited
operator [](String key) String?
Returns the raw string value stored at key, or null when absent.
override
operator []=(String key, String? value) → void
Writes value at key.
override