getPropertyAs<T> abstract method
The value of the property key converted to T, or defaultValue
when no source has it.
The resolver's ConversionService converts, so every type it knows
works (int, bool, Duration, List<String>, ...). defaultValue
is also used when the value converts to null, as a blank string
does. Throws a ConversionException when the text cannot be
converted (port=abc read as int).
final timeout = resolver.getPropertyAs<Duration>('http.timeout');
final hosts = resolver.getPropertyAs<List<String>>('cluster.hosts');
Implementation
T? getPropertyAs<T>(String key, {T? defaultValue});