Unverified Commit a9b4c145 authored by Per Classon's avatar Per Classon Committed by GitHub

[Material] Decoration for DataTable is not used inside PaginatedDataTable (#70603)

parent de884f1a
......@@ -61,6 +61,10 @@ class PaginatedDataTable extends StatefulWidget {
///
/// The [rowsPerPage] and [availableRowsPerPage] must not be null (they
/// both have defaults, though, so don't have to be specified).
///
/// Themed by [DataTableTheme]. [DataTableThemeData.decoration] is ignored.
/// To modify the border or background color of the [PaginatedDataTable], use
/// [CardTheme], since a [Card] wraps the inner [DataTable].
PaginatedDataTable({
Key? key,
this.header,
......@@ -471,6 +475,9 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
sortColumnIndex: widget.sortColumnIndex,
sortAscending: widget.sortAscending,
onSelectAll: widget.onSelectAll,
// Make sure no decoration is set on the DataTable
// from the theme, as its already wrapped in a Card.
decoration: const BoxDecoration(),
dataRowHeight: widget.dataRowHeight,
headingRowHeight: widget.headingRowHeight,
horizontalMargin: widget.horizontalMargin,
......
......@@ -786,4 +786,36 @@ void main() {
await tester.pumpWidget(buildTable(false));
expect(find.byType(Checkbox), findsNothing);
});
testWidgets('Table should not use decoration from DataTableTheme', (WidgetTester tester) async {
final Size originalSize = binding.renderView.size;
await binding.setSurfaceSize(const Size(800, 800));
Widget buildTable() {
return MaterialApp(
theme: ThemeData.light().copyWith(
dataTableTheme: const DataTableThemeData(
decoration: BoxDecoration(color: Colors.white),
),
),
home: PaginatedDataTable(
header: const Text('Test table'),
source: TestDataSource(onSelectChanged: (bool? value) {}),
showCheckboxColumn: true,
columns: const <DataColumn>[
DataColumn(label: Text('Name')),
DataColumn(label: Text('Calories'), numeric: true),
DataColumn(label: Text('Generation')),
],
),
);
}
await tester.pumpWidget(buildTable());
final Finder tableContainerFinder = find.ancestor(of: find.byType(Table), matching: find.byType(Container)).first;
expect(tester.widget<Container>(tableContainerFinder).decoration, const BoxDecoration());
// Reset the surface size.
await binding.setSurfaceSize(originalSize);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment