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": "<WidgetStateProperty<Color>>",
"dataRowCursor": "<WidgetStateProperty<MouseCursor>",
"dataRowMaxHeight": "<double>",
"dataRowMinHeight": "<double>",
"dataTextStyle": "<TextStyle,
"decoration": "<BoxDecoration>",
"dividerThickness": "<double>",
"headingCellCursor": "<WidgetStateProperty<MouseCursor>",
"headingRowColor": "<WidgetStateProperty<Color>>",
"headingRowHeight": "<double>",
"headingTextStyle": "<TextStyle>",
"horizontalMargin": "<double>"
}
This will use the properties passed through JSON to create the WidgetStateProperty of each corresponding property by using the WidgetStateProperty.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.maybeParseDouble(
value['checkboxHorizontalMargin'],
),
columnSpacing: JsonClass.maybeParseDouble(
value['columnSpacing'],
),
dataRowColor: decodeWidgetStatePropertyColor(
value['dataRowColor'],
validate: false,
),
dataRowCursor: decodeWidgetStatePropertyMouseCursor(
value['dataRowCursor'],
validate: false,
),
// @deprecated
// dataRowHeight:
dataRowMaxHeight: JsonClass.maybeParseDouble(
value['dataRowMaxHeight'],
),
dataRowMinHeight: JsonClass.maybeParseDouble(
value['dataRowMinHeight'],
),
dataTextStyle: decodeTextStyle(
value['dataTextStyle'],
validate: false,
),
decoration: decodeBoxDecoration(
value['decoration'],
validate: false,
),
dividerThickness: JsonClass.maybeParseDouble(
value['dividerThickness'],
),
headingCellCursor: decodeWidgetStatePropertyMouseCursor(
value['dataRowCursor'],
validate: false,
),
headingRowColor: decodeWidgetStatePropertyColor(
value['headingRowColor'],
validate: false,
),
headingRowHeight: JsonClass.maybeParseDouble(
value['headingRowHeight'],
),
headingTextStyle: decodeTextStyle(
value['headingTextStyle'],
validate: false,
),
horizontalMargin: JsonClass.maybeParseDouble(
value['horizontalMargin'],
),
);
}
return result;
}