decodeDialogTheme static method

DialogTheme? decodeDialogTheme(
  1. dynamic value, {
  2. bool validate = true,
})

Decodes the given value to an DialogTheme. This expects the given value to follow the structure below:

{
  "backgroundColor": <Color>,
  "contentTextStyle": <TextStyle>,
  "elevation": <double>,
  "shape": <ShapeBorder>,
  "titleTextStyle": <TextStyle>
}

See also:

Implementation

static DialogTheme? decodeDialogTheme(
  dynamic value, {
  bool validate = true,
}) {
  DialogTheme? result;

  if (value is DialogTheme) {
    result = value;
  } else if (value != null) {
    assert(SchemaValidator.validate(
      schemaId: '$_baseSchemaUrl/dialog_theme',
      value: value,
      validate: validate,
    ));
    result = DialogTheme(
      backgroundColor: decodeColor(
        value['backgroundColor'],
        validate: false,
      ),
      contentTextStyle: decodeTextStyle(
        value['contentTextStyle'],
        validate: false,
      ),
      elevation: JsonClass.parseDouble(value['elevation']),
      shape: decodeShapeBorder(
        value['shape'],
        validate: false,
      ),
      titleTextStyle: decodeTextStyle(
        value['titleTextStyle'],
        validate: false,
      ),
    );
  }

  return result;
}