attributeToBool function

bool attributeToBool(
  1. String inputValue, {
  2. bool defaultValue = false,
})

Parses HTML attribute String to a bool.

Should be used to parse values passed to @Attribute constructor argument.

This does not follow the HTML boolean attribute definition (https://stackoverflow.com/a/4139805), as 'false' String will be parsed to false value.

When no attribute is present defaultValue value is returned.

NOTE: no attribute is not the same as no value for attribute:

Implementation

bool attributeToBool(String inputValue, {bool defaultValue = false}) {
  if (inputValue == null) return defaultValue;
  return _parseBool(inputValue);
}