getDouble method

double getDouble(
  1. String key, [
  2. double? defaultValue
])

Get a double associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned. If no default value is provided and throwExceptionOnMissing is true then a NoSuchElementException is thrown. If throwExceptionOnMissing is false then 0.0 is returned. If the value exists then interpolation is performed before returning it. The returned double is never null. Throws ConversionException if the value cannot be converted to double.

Implementation

double getDouble(String key, [double? defaultValue]) {
  Object? value = _resolveContainerStore(key);

  if (value == null) {
    if (defaultValue != null) {
      return defaultValue;
    } else {
      if (throwExceptionOnMissing) {
        throw NoSuchElementException(
            "$key doesn't map to an existing object");
      } else {
        return 0.0;
      }
    }
  } else {
    return PropertyConverter().toDouble(interpolate(value));
  }
}