decodeDataTableThemeData static method
Decodes the given value
to an DataTableThemeData. This expects the
given value
to be of the following structure:
{
"checkboxHorizontalMargin": <double>,
"columnSpacing": <double>,
"dataRowColor": <MaterialStateProperty<Color>>,
"dataRowHeight": <double>,
"dataTextStyle": <TextStyle,
"decoration": <BoxDecoration>,
"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(
checkboxHorizontalMargin: JsonClass.parseDouble(
value['checkboxHorizontalMargin'],
),
columnSpacing: JsonClass.parseDouble(
value['columnSpacing'],
),
dataRowColor: decodeMaterialStatePropertyColor(
value['dataRowColor'],
validate: false,
),
dataRowHeight: JsonClass.parseDouble(
value['dataRowHeight'],
),
dataTextStyle: decodeTextStyle(
value['dataTextStyle'],
validate: false,
),
decoration: decodeBoxDecoration(
value['decoration'],
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;
}