# getPropertyAs<T> method

1. @override

T? getPropertyAs<T>(

1. String key,
2. Class<T> targetType, [
3. T? defaultValue

])

Retrieves and converts the value of `key` to the desired type `T`.

If `defaultValue` is provided, it returns the default value instead of null.

Returns `null` if the property is not found or cannot be converted.

targetType - the expected type of the property value key - the property key

### Example:

    final port = resolver.getPropertyAs<int>('server.port', Class<int>());
    final port = resolver.getPropertyAs<int>('server.port', Class<int>(), 8080);

## Implementation

    @override
    T? getPropertyAs<T>(String key, Class<T> targetType, [T? defaultValue]) {
    	return _propertyResolver.getPropertyAs(key, targetType, defaultValue);
    }