decodeAppBarTheme static method

AppBarTheme? decodeAppBarTheme(
  1. dynamic value, {
  2. bool validate = true,
})

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

{
  "actionsIconTheme": <IconThemeData>,
  "backgroundColor": <Color>,
  "backwardsCompatibility": <bool>,
  "brightness": <Brightness>,
  "centerTitle": <bool>,
  "color": <Color>,
  "elevation": <double>,
  "foregroundColor": <Color>,
  "iconTheme": <IconThemeData>,
  "shadowColor": <Color>,
  "systemOverlayStyle": <SystemUiOverlayStyle>,
  "textTheme": <TextTheme>,
  "titleSpacing": <double>,
  "titleTextStyle": <TextStyle>,
  "toolbarTextStyle": <TextStyle>
}

See also:

Implementation

static AppBarTheme? decodeAppBarTheme(
  dynamic value, {
  bool validate = true,
}) {
  AppBarTheme? result;

  if (value is AppBarTheme) {
    result = value;
  } else if (value != null) {
    assert(SchemaValidator.validate(
      schemaId: '$_baseSchemaUrl/app_bar_theme',
      value: value,
      validate: validate,
    ));
    result = AppBarTheme(
      actionsIconTheme: decodeIconThemeData(
        value['actionsIconTheme'],
        validate: false,
      ),
      backgroundColor: decodeColor(
        value['backgroundColor'] ?? value['color'],
        validate: false,
      ),
      backwardsCompatibility: value['backwardsCompatibility'] == null
          ? null
          : JsonClass.parseBool(
              value['backwardsCompatibility'],
            ),
      brightness: decodeBrightness(
        value['brightness'],
        validate: false,
      ),
      centerTitle: value['centerTitle'] == null
          ? null
          : JsonClass.parseBool(value['centerTitle']),
      elevation: JsonClass.parseDouble(value['elevation']),
      foregroundColor: decodeColor(
        value['foregroundColor'],
        validate: false,
      ),
      iconTheme: decodeIconThemeData(
        value['iconTheme'],
        validate: false,
      ),
      shadowColor: decodeColor(
        value['shadowColor'],
        validate: false,
      ),
      systemOverlayStyle: decodeSystemUiOverlayStyle(
        value['systemOverlayStyle'],
        validate: false,
      ),
      textTheme: decodeTextTheme(
        value['textTheme'],
        validate: false,
      ),
      titleSpacing: JsonClass.parseDouble(value['titleSpacing']),
      titleTextStyle: decodeTextStyle(
        value['titleTextStyle'],
        validate: false,
      ),
      toolbarTextStyle: decodeTextStyle(
        value['toolbarTextStyle'],
        validate: false,
      ),
    );
  }

  return result;
}