Skip to content

Commit 1b1c8a1

Browse files
Fixed PaginatedDataTable not using dataRowMinHeight and dataRowMaxHeight from Theme (#133634)
`PaginatedDataTable` will now make use of `dataRowMinHeight` and `dataRowMaxHeight` from the Theme *List which issues are fixed by this PR. You must list at least one issue.* Resolves #133633
1 parent eb77b52 commit 1b1c8a1

File tree

2 files changed

+37
-5
lines changed

2 files changed

+37
-5
lines changed

packages/flutter/lib/src/material/paginated_data_table.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ class PaginatedDataTable extends StatefulWidget {
122122
assert(dataRowMinHeight == null || dataRowMaxHeight == null || dataRowMaxHeight >= dataRowMinHeight),
123123
assert(dataRowHeight == null || (dataRowMinHeight == null && dataRowMaxHeight == null),
124124
'dataRowHeight ($dataRowHeight) must not be set if dataRowMinHeight ($dataRowMinHeight) or dataRowMaxHeight ($dataRowMaxHeight) are set.'),
125-
dataRowMinHeight = dataRowHeight ?? dataRowMinHeight ?? kMinInteractiveDimension,
126-
dataRowMaxHeight = dataRowHeight ?? dataRowMaxHeight ?? kMinInteractiveDimension,
125+
dataRowMinHeight = dataRowHeight ?? dataRowMinHeight,
126+
dataRowMaxHeight = dataRowHeight ?? dataRowMaxHeight,
127127
assert(rowsPerPage > 0),
128128
assert(() {
129129
if (onRowsPerPageChanged != null) {
@@ -192,13 +192,13 @@ class PaginatedDataTable extends StatefulWidget {
192192
///
193193
/// This value is optional and defaults to [kMinInteractiveDimension] if not
194194
/// specified.
195-
final double dataRowMinHeight;
195+
final double? dataRowMinHeight;
196196

197197
/// The maximum height of each row (excluding the row that contains column headings).
198198
///
199-
/// This value is optional and defaults to kMinInteractiveDimension if not
199+
/// This value is optional and defaults to [kMinInteractiveDimension] if not
200200
/// specified.
201-
final double dataRowMaxHeight;
201+
final double? dataRowMaxHeight;
202202

203203
/// The height of the heading row.
204204
///

packages/flutter/test/material/paginated_data_table_test.dart

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,38 @@ void main() {
10221022
await binding.setSurfaceSize(originalSize);
10231023
});
10241024

1025+
testWidgets('dataRowMinHeight & dataRowMaxHeight if not set will use DataTableTheme', (WidgetTester tester) async {
1026+
addTearDown(() => binding.setSurfaceSize(null));
1027+
await binding.setSurfaceSize(const Size(800, 800));
1028+
1029+
const double minMaxDataRowHeight = 30.0;
1030+
1031+
await tester.pumpWidget(MaterialApp(
1032+
theme: ThemeData(
1033+
dataTableTheme: const DataTableThemeData(
1034+
dataRowMinHeight: minMaxDataRowHeight,
1035+
dataRowMaxHeight: minMaxDataRowHeight,
1036+
),
1037+
),
1038+
home: PaginatedDataTable(
1039+
header: const Text('Test table'),
1040+
source: TestDataSource(allowSelection: true),
1041+
columns: const <DataColumn>[
1042+
DataColumn(label: Text('Name')),
1043+
DataColumn(label: Text('Calories'), numeric: true),
1044+
DataColumn(label: Text('Generation')),
1045+
],
1046+
),
1047+
));
1048+
1049+
final Container rowContainer = tester.widget<Container>(find.descendant(
1050+
of: find.byType(Table),
1051+
matching: find.byType(Container),
1052+
).last);
1053+
expect(rowContainer.constraints?.minHeight, minMaxDataRowHeight);
1054+
expect(rowContainer.constraints?.maxHeight, minMaxDataRowHeight);
1055+
});
1056+
10251057
testWidgets('PaginatedDataTable custom checkboxHorizontalMargin properly applied', (WidgetTester tester) async {
10261058
const double customCheckboxHorizontalMargin = 15.0;
10271059
const double customHorizontalMargin = 10.0;

0 commit comments

Comments
 (0)