toBooleanWithDefault static method

bool toBooleanWithDefault(
  1. dynamic value,
  2. bool defaultValue
)

Converts value into boolean or returns default value when conversion is not possible

  • value the value to convert.
  • defaultValue the default value Returns boolean value or default when conversion is not supported.

See toNullableBoolean

Implementation

static bool toBooleanWithDefault(value, bool defaultValue) {
  var result = BooleanConverter.toNullableBoolean(value);
  return result ?? defaultValue;
}