decodeBrightness static method

Brightness? decodeBrightness(
  1. dynamic value, {
  2. bool validate = true,
})

Decodes the value to a Brightness. Supported values are:

  • light
  • dark

Implementation

static Brightness? decodeBrightness(
  dynamic value, {
  bool validate = true,
}) {
  Brightness? result;

  if (value is Brightness) {
    result = value;
  } else if (value != null) {
    assert(SchemaValidator.validate(
      schemaId: '$_baseSchemaUrl/brightness',
      value: value,
      validate: validate,
    ));
    result = value == 'light'
        ? Brightness.light
        : value == 'dark'
            ? Brightness.dark
            : null;
  }

  return result;
}