decodeCupertinoThemeData static method

CupertinoThemeData? decodeCupertinoThemeData(
  1. dynamic value, {
  2. bool validate = true,
})

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

{
  "barBackgroundColor": <Color>,
  "brightness": <Brightness>,
  "primaryColor": <Color>,
  "primaryContrastingColor": <Color>,
  "scaffoldBackgroundColor": <Color>,
  "textTheme": <CupertinoTextThemeData>
}

See also:

Implementation

static CupertinoThemeData? decodeCupertinoThemeData(
  dynamic value, {
  bool validate = true,
}) {
  CupertinoThemeData? result;

  if (value is CupertinoThemeData) {
    result = value;
  } else if (value != null) {
    assert(SchemaValidator.validate(
      schemaId: '$_baseSchemaUrl/cupertino_theme_data',
      value: value,
      validate: validate,
    ));
    result = CupertinoThemeData(
      barBackgroundColor: decodeColor(
        value['barBackgroundColor'],
        validate: false,
      ),
      brightness: decodeBrightness(
        value['brightness'],
        validate: false,
      ),
      primaryColor: decodeColor(
        value['primaryColor'],
        validate: false,
      ),
      primaryContrastingColor: decodeColor(
        value['primaryContrastingColor'],
        validate: false,
      ),
      scaffoldBackgroundColor: decodeColor(
        value['scaffoldBackgroundColor'],
        validate: false,
      ),
      textTheme: decodeCupertinoTextThemeData(
        value['textTheme'],
        validate: false,
      ),
    );
  }

  return result;
}