PropertyResolver class abstract
A service abstraction for resolving application properties and configuration values.
This interface defines methods for reading, converting, and resolving
property values from environment variables, .env, YAML, or other sources.
Useful for configuration loading, dynamic placeholder resolution, and runtime property injection.
π§ Common Use Cases:
final port = resolver.getPropertyAsWithDefault<int>('server.port', 8080);
final name = resolver.getRequiredProperty('app.name');
final message = resolver.resolvePlaceholders('Running #{app.name} on port #{server.port}');
Supported Patterns
Environment Variables:
${VAR_NAME}- Standard shell-style environment variable#{VAR_NAME}- Alternative environment variable syntax$VAR_NAME- Short environment variable syntax#VAR_NAME- Alternative short environment variable syntax
Property References:
@property.name@- Property reference with @ delimiters${property.name}- Property reference using ${} syntax#{property.name}- Property reference using #{} syntax
Example Usage
// Environment: BASE_URL=https://api.example.com, API=v1
// Properties: server.timeout=30, app.name=MyApp
final interpolator = ResourceInterpolator(resources);
// Various interpolation patterns:
interpolator.interpolate('${BASE_URL}/${API}') // β https://api.example.com/v1
interpolator.interpolate('#{BASE_URL}/#{API}') // β https://api.example.com/v1
interpolator.interpolate('$BASE_URL/$API') // β https://api.example.com/v1
interpolator.interpolate('#BASE_URL/#API') // β https://api.example.com/v1
interpolator.interpolate('$BASE_URL/check') // β https://api.example.com/check
interpolator.interpolate('@app.name@ timeout: @server.timeout@s') // β MyApp timeout: 30s
- Implementers
Constructors
- PropertyResolver()
-
A service abstraction for resolving application properties and configuration values.
const
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
-
containsProperty(
String key) β bool -
Returns whether the given property
keyis defined. -
getProperty(
String key, [String? defaultValue]) β String? -
Retrieves the value for the given property
key, ornullif not found. -
getPropertyAs<
T> (String key, Class< T> targetType, [T? defaultValue]) β T? -
Retrieves and converts the value of
keyto the desired typeT. -
getRequiredProperty(
String key) β String -
Returns the property value for
key, or throwsIllegalStateExceptionif the property is not defined. -
getRequiredPropertyAs<
T> (String key, Class< T> targetType) β T -
Retrieves and converts the property
keyto typeT, or throwsIllegalStateExceptionif missing or invalid. -
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. -
resolveRequiredPlaceholders(
String text) β String -
Resolves
#{...}placeholders in the inputtextusing available properties. -
suggestions(
String key) β List< String> - Returns a list of suggestions for the given key.
-
toString(
) β String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) β bool -
The equality operator.
inherited