mirror of
https://github.com/flutter/flutter
synced 2024-10-13 11:42:54 +00:00
[Material] Decoration for DataTable is not used inside PaginatedDataTable (#70603)
This commit is contained in:
parent
de884f1afe
commit
a9b4c1454b
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue