ConfigurableEnvironment class abstract
A configurable extension of the Environment interface that allows mutation of environment internals such as active profiles and property sources.
This interface exposes:
propertySources: the mutable stack of PropertySources used for resolving properties.setActiveProfiles: to explicitly set the profiles considered active during configuration.setDefaultProfiles: to define fallback profiles when no active profiles are provided.
It is typically implemented by core environment types like
AbstractEnvironment and StandardEnvironment.
Example usage:
final env = StandardEnvironment();
env.setActiveProfiles(['dev']);
env.setDefaultProfiles(['default']);
env.propertySources.addLast(
MapPropertySource('app', {'debug': 'true'}),
);
print(env.getProperty('debug')); // true
Use this interface when building frameworks or apps that require profile-based configuration or dynamic property source injection.
- Inheritance
-
- Object
- PropertyResolver
- Environment
- ConfigurableEnvironment
- Implemented types
- Implementers
Constructors
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
-
acceptsProfiles(
Profiles profiles) → bool -
Profile Predicate Evaluation
inherited
-
addActiveProfile(
String profile) → void - Adds an additional active profile to the current set.
-
containsProperty(
String key) → bool -
Returns whether the given property
keyis defined.inherited -
getActiveProfiles(
) → List< String> -
Active Profiles
inherited
-
getConversionService(
) → ConfigurableConversionService -
Returns the
ConfigurableConversionServiceused to perform type conversions.inherited -
getDefaultProfiles(
) → List< String> -
Default Profiles
inherited
-
getPackageName(
) → String -
Represents an abstraction for identifying the package that an object,
resource, or service belongs to.
inherited
-
getProperty(
String key, [String? defaultValue]) → String? -
Retrieves the value for the given property
key, ornullif not found.inherited -
getPropertyAs<
T> (String key, Class< T> targetType, [T? defaultValue]) → T? -
Retrieves and converts the value of
keyto the desired typeT.inherited -
getPropertySources(
) → MutablePropertySources - Returns the MutablePropertySources backing this environment.
-
getRequiredProperty(
String key) → String -
Returns the property value for
key, or throwsIllegalStateExceptionif the property is not defined.inherited -
getRequiredPropertyAs<
T> (String key, Class< T> targetType) → T -
Retrieves and converts the property
keyto typeT, or throwsIllegalStateExceptionif missing or invalid.inherited -
getSystemEnvironment(
) → Map< String, String> - Returns the environment variables of the underlying OS.
-
getSystemProperties(
) → Map< String, String> -
Returns the system properties available to the Dart VM (if any),
such as those passed via
--defineor custom bootstrap logic. -
matchesProfiles(
List< String> profileExpressions) → bool -
Profile Expression Matcher
inherited
-
merge(
ConfigurableEnvironment parent) → void - Merges another ConfigurableEnvironment into this one.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
resolvePlaceholders(
String text) → String -
Resolves
#{...}placeholders in the inputtextusing available properties.inherited -
resolveRequiredPlaceholders(
String text) → String -
Resolves
#{...}placeholders in the inputtextusing available properties.inherited -
setActiveProfiles(
List< String> profiles) → void - Replaces the current set of active profiles with the given list.
-
setConversionService(
ConfigurableConversionService conversionService) → void -
Replaces the underlying
ConfigurableConversionServiceused for type conversions.inherited -
setDefaultProfiles(
List< String> profiles) → void - Defines the default profiles to fall back on when no active profiles have been explicitly set.
-
setEscapeCharacter(
Character? escapeCharacter) → void -
Sets the escape character used to ignore placeholder prefix and separator.
inherited
-
setIgnoreUnresolvableNestedPlaceholders(
bool ignoreUnresolvableNestedPlaceholders) → void -
Enables or disables ignoring unresolvable nested placeholders.
inherited
-
setPlaceholderPrefix(
String placeholderPrefix) → void -
Sets the prefix that identifies a placeholder in property values.
inherited
-
setPlaceholderSuffix(
String placeholderSuffix) → void -
Sets the suffix that identifies the end of a placeholder in property values.
inherited
-
setRequiredProperties(
List< String> requiredProperties) → void -
Sets the list of property names that are required to be present and non-null.
inherited
-
setValueSeparator(
String? valueSeparator) → void -
Sets the separator for default values within placeholders.
inherited
-
suggestions(
String key) → List< String> -
Configuration Suggestions
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
validateRequiredProperties(
) → void -
Validates that all required properties are present and non-null.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited