Skip to content

Commit

Permalink
Fixed PaginatedDataTable not using dataRowMinHeight and `dataRowM…
Browse files Browse the repository at this point in the history
…axHeight` 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
  • Loading branch information
MarkOSullivan94 authored Sep 1, 2023
1 parent eb77b52 commit 1b1c8a1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/flutter/lib/src/material/paginated_data_table.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ class PaginatedDataTable extends StatefulWidget {
assert(dataRowMinHeight == null || dataRowMaxHeight == null || dataRowMaxHeight >= dataRowMinHeight),
assert(dataRowHeight == null || (dataRowMinHeight == null && dataRowMaxHeight == null),
'dataRowHeight ($dataRowHeight) must not be set if dataRowMinHeight ($dataRowMinHeight) or dataRowMaxHeight ($dataRowMaxHeight) are set.'),
dataRowMinHeight = dataRowHeight ?? dataRowMinHeight ?? kMinInteractiveDimension,
dataRowMaxHeight = dataRowHeight ?? dataRowMaxHeight ?? kMinInteractiveDimension,
dataRowMinHeight = dataRowHeight ?? dataRowMinHeight,
dataRowMaxHeight = dataRowHeight ?? dataRowMaxHeight,
assert(rowsPerPage > 0),
assert(() {
if (onRowsPerPageChanged != null) {
Expand Down Expand Up @@ -192,13 +192,13 @@ class PaginatedDataTable extends StatefulWidget {
///
/// This value is optional and defaults to [kMinInteractiveDimension] if not
/// specified.
final double dataRowMinHeight;
final double? dataRowMinHeight;

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

/// The height of the heading row.
///
Expand Down
32 changes: 32 additions & 0 deletions packages/flutter/test/material/paginated_data_table_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,38 @@ void main() {
await binding.setSurfaceSize(originalSize);
});

testWidgets('dataRowMinHeight & dataRowMaxHeight if not set will use DataTableTheme', (WidgetTester tester) async {
addTearDown(() => binding.setSurfaceSize(null));
await binding.setSurfaceSize(const Size(800, 800));

const double minMaxDataRowHeight = 30.0;

await tester.pumpWidget(MaterialApp(
theme: ThemeData(
dataTableTheme: const DataTableThemeData(
dataRowMinHeight: minMaxDataRowHeight,
dataRowMaxHeight: minMaxDataRowHeight,
),
),
home: PaginatedDataTable(
header: const Text('Test table'),
source: TestDataSource(allowSelection: true),
columns: const <DataColumn>[
DataColumn(label: Text('Name')),
DataColumn(label: Text('Calories'), numeric: true),
DataColumn(label: Text('Generation')),
],
),
));

final Container rowContainer = tester.widget<Container>(find.descendant(
of: find.byType(Table),
matching: find.byType(Container),
).last);
expect(rowContainer.constraints?.minHeight, minMaxDataRowHeight);
expect(rowContainer.constraints?.maxHeight, minMaxDataRowHeight);
});

testWidgets('PaginatedDataTable custom checkboxHorizontalMargin properly applied', (WidgetTester tester) async {
const double customCheckboxHorizontalMargin = 15.0;
const double customHorizontalMargin = 10.0;
Expand Down

0 comments on commit 1b1c8a1

Please sign in to comment.