getDouble static method

double getDouble(
  1. UIDefaults? defaults,
  2. double? defaultProp,
  3. double? overrideWith,
  4. double defaultTo,
)

Get Double returns a double based on UIDefaults or overridden properties

Implementation

static double getDouble(UIDefaults? defaults, double? defaultProp, double? overrideWith, double defaultTo) {
  /// if defaults is defined
  if (defaults != null) {
    ///
    /// Check if an override property is set
    /// if so, use it
    if (overrideWith != null) return overrideWith;

    /// if the current prop is not set in [UIDefaults]
    /// use override prop or a default one
    if (defaultProp == null) {
      return overrideWith ?? defaultTo;
    }

    /// If the passed default prop is set, use it.
    return defaultProp;
  }

  /// if defaults is null
  /// try to set [overrideWith] orhterwuse defaults to [defaultTo]
  return overrideWith ?? defaultTo;
}