decodeSnackBarThemeData static method

SnackBarThemeData? decodeSnackBarThemeData(
  1. dynamic value, {
  2. bool validate = true,
})

Decodes the given value to a SnackBarThemeData. This expects the value to have the following structure:

{
  "actionTextColor": <Color>,
  "backgroundColor": <Color>,
  "behavior": <SnackBarBehavior>,
  "contentTextStyle": <TextStyle>,
  "disabledActionTextColor": <Color>,
  "elevation": <double>,
  "shape": <ShapeBorder>,
}

See also:

Implementation

static SnackBarThemeData? decodeSnackBarThemeData(
  dynamic value, {
  bool validate = true,
}) {
  SnackBarThemeData? result;

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

  return result;
}