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: 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,
      ),
      scrolledUnderElevation: JsonClass.parseDouble(
        value['scrolledUnderElevation'],
      ),
      shape: ThemeDecoder.decodeShapeBorder(value['shape']),
      shadowColor: decodeColor(
        value['shadowColor'],
        validate: false,
      ),
      systemOverlayStyle: decodeSystemUiOverlayStyle(
        value['systemOverlayStyle'],
        validate: false,
      ),
      surfaceTintColor: decodeColor(
        value['surfaceTintColor'],
        validate: false,
      ),
      titleSpacing: JsonClass.parseDouble(value['titleSpacing']),
      titleTextStyle: decodeTextStyle(
        value['titleTextStyle'],
        validate: false,
      ),
      toolbarHeight: JsonClass.parseDouble(value['toolbarHeight']),
      toolbarTextStyle: decodeTextStyle(
        value['toolbarTextStyle'],
        validate: false,
      ),
    );
  }

  return result;
}