PropertyResolver constructor
const
PropertyResolver()
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
Implementation
const PropertyResolver();