Fix DataTableThemeData.copyWith handling of dataRowHeight (#126943)

Fixes https://github.com/flutter/flutter/issues/126676
This commit is contained in:
Jason Simmons 2023-05-16 14:44:24 -07:00 committed by GitHub
parent 60751ca519
commit e24c64d8ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -137,10 +137,14 @@ class DataTableThemeData with Diagnosticable {
MaterialStateProperty<MouseCursor?>? headingCellCursor,
MaterialStateProperty<MouseCursor?>? dataRowCursor,
}) {
assert(dataRowHeight == null || (dataRowMinHeight == null && dataRowMaxHeight == null),
'dataRowHeight ($dataRowHeight) must not be set if dataRowMinHeight ($dataRowMinHeight) or dataRowMaxHeight ($dataRowMaxHeight) are set.');
dataRowMinHeight = dataRowHeight ?? dataRowMinHeight;
dataRowMaxHeight = dataRowHeight ?? dataRowMaxHeight;
return DataTableThemeData(
decoration: decoration ?? this.decoration,
dataRowColor: dataRowColor ?? this.dataRowColor,
dataRowHeight: dataRowHeight ?? this.dataRowHeight,
dataRowMinHeight: dataRowMinHeight ?? this.dataRowMinHeight,
dataRowMaxHeight: dataRowMaxHeight ?? this.dataRowMaxHeight,
dataTextStyle: dataTextStyle ?? this.dataTextStyle,

View File

@ -13,6 +13,16 @@ void main() {
expect(const DataTableThemeData().hashCode, const DataTableThemeData().copyWith().hashCode);
});
test('DataTableThemeData copyWith dataRowHeight', () {
const DataTableThemeData themeData = DataTableThemeData(
dataRowMinHeight: 10,
dataRowMaxHeight: 10,
);
expect(themeData, themeData.copyWith());
expect(themeData.copyWith(dataRowMinHeight: 20, dataRowMaxHeight: 20),
themeData.copyWith(dataRowHeight: 20));
});
test('DataTableThemeData lerp special cases', () {
const DataTableThemeData data = DataTableThemeData();
expect(identical(DataTableThemeData.lerp(data, data, 0.5), data), true);