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>",
  "centerTitle": "<bool>",
  "elevation": "<double>",
  "foregroundColor": "<Color>",
  "iconTheme": "<IconThemeData>",
  "scrolledUnderElevation": "<double>",
  "shadowColor": "<Color>",
  "surfaceTintColor": "<Color>",
  "systemOverlayStyle": "<SystemUiOverlayStyle>",
  "titleSpacing": "<double>",
  "titleTextStyle": "<TextStyle>",
  "toolbarHeight": "<double>",
  "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,
      ),
      centerTitle: JsonClass.maybeParseBool(value['centerTitle']),
      // Covered via backgroundColor
      // color:
      elevation: JsonClass.maybeParseDouble(value['elevation']),
      foregroundColor: decodeColor(
        value['foregroundColor'],
        validate: false,
      ),
      iconTheme: decodeIconThemeData(
        value['iconTheme'],
        validate: false,
      ),
      scrolledUnderElevation: JsonClass.maybeParseDouble(
        value['scrolledUnderElevation'],
      ),
      shape: ThemeDecoder.decodeShapeBorder(
        value['shape'],
        validate: false,
      ),
      shadowColor: decodeColor(
        value['shadowColor'],
        validate: false,
      ),
      systemOverlayStyle: decodeSystemUiOverlayStyle(
        value['systemOverlayStyle'],
        validate: false,
      ),
      surfaceTintColor: decodeColor(
        value['surfaceTintColor'],
        validate: false,
      ),
      titleSpacing: JsonClass.maybeParseDouble(value['titleSpacing']),
      titleTextStyle: decodeTextStyle(
        value['titleTextStyle'],
        validate: false,
      ),
      toolbarHeight: JsonClass.maybeParseDouble(value['toolbarHeight']),
      toolbarTextStyle: decodeTextStyle(
        value['toolbarTextStyle'],
        validate: false,
      ),
    );
  }

  return result;
}