decodeDataTableThemeData static method

DataTableThemeData? decodeDataTableThemeData(
  1. dynamic value, {
  2. bool validate = true,
})

Decodes the given value to an DataTableThemeData. This expects the given value to be of the following structure:

{
  "columnSpacing": <double>,
  "dataRowColor": <MaterialStateProperty<Color>>,
  "dataRowHeight": <double>,
  "dataTextStyle": <TextStyle,
  "dividerThickness": <double>,
  "headingRowColor": <MaterialStateProperty<Color>>,
  "headingRowHeight": <double>,
  "headingTextStyle": <TextStyle>,
  "horizontalMargin": <double>
}

This will use the properties passed through JSON to create the MaterialStateProperty of each corresponding property by using the MaterialStateProperty.all function with the value passed in.

See also:

Implementation

static DataTableThemeData? decodeDataTableThemeData(
  dynamic value, {
  bool validate = true,
}) {
  DataTableThemeData? result;

  if (value is DataTableThemeData) {
    result = value;
  } else if (value != null) {
    assert(SchemaValidator.validate(
      schemaId: '$_baseSchemaUrl/data_table_theme_data',
      value: value,
      validate: validate,
    ));
    result = DataTableThemeData(
      columnSpacing: JsonClass.parseDouble(
        value['columnSpacing'],
      ),
      dataRowColor: decodeMaterialStatePropertyColor(
        value['dataRowColor'],
        validate: false,
      ),
      dataRowHeight: JsonClass.parseDouble(
        value['dataRowHeight'],
      ),
      dataTextStyle: decodeTextStyle(
        value['dataTextStyle'],
        validate: false,
      ),
      dividerThickness: JsonClass.parseDouble(
        value['dividerThickness'],
      ),
      headingRowColor: decodeMaterialStatePropertyColor(
        value['headingRowColor'],
        validate: false,
      ),
      headingRowHeight: JsonClass.parseDouble(
        value['headingRowHeight'],
      ),
      headingTextStyle: decodeTextStyle(
        value['headingTextStyle'],
        validate: false,
      ),
      horizontalMargin: JsonClass.parseDouble(
        value['horizontalMargin'],
      ),
    );
  }

  return result;
}