ConfigurationBuilder class final
Assembles a ConfigurationRoot from one or more ConfigurationSources.
Sources are evaluated in registration order; the last source added always wins when multiple sources define the same key.
final config = ConfigurationBuilder()
.addInMemory({'app:name': 'Orders', 'app:version': '1.0'})
.addJsonFile('appsettings.json')
.addJsonFile('appsettings.production.json', optional: true)
.addEnvironmentVariables(prefix: 'APP_')
.build();
print(config['app:name']);
Constructors
- ConfigurationBuilder()
- Creates a ConfigurationBuilder with no initial sources.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
sources
→ List<
ConfigurationSource> -
The read-only list of sources added so far.
no setter
Methods
-
add(
ConfigurationSource source) → ConfigurationBuilder - Adds a ConfigurationSource directly.
-
addEnvironmentVariables(
{String prefix = ''}) → ConfigurationBuilder - Adds an EnvironmentConfigurationSource.
-
addInMemory(
Map< String, String?> initialData) → ConfigurationBuilder - Adds key-value pairs from an in-memory Map<String, String?>.
-
addJsonFile(
String filePath, {bool optional = false, bool reloadOnChange = false}) → ConfigurationBuilder -
Adds a JsonFileConfigurationSource that loads from
filePath. -
addJsonString(
String jsonContent) → ConfigurationBuilder -
Adds a JsonStringConfigurationSource that parses
jsonContentdirectly. -
addMap(
Map< String, dynamic> map) → ConfigurationBuilder -
Adds a generic
Map<String, dynamic>provider. -
build(
) → ConfigurationRoot - Builds and returns a ConfigurationRoot from the registered sources.
-
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