diff --git a/packages/flutter/lib/src/material/paginated_data_table.dart b/packages/flutter/lib/src/material/paginated_data_table.dart index f30cff9903..06140bebb8 100644 --- a/packages/flutter/lib/src/material/paginated_data_table.dart +++ b/packages/flutter/lib/src/material/paginated_data_table.dart @@ -17,6 +17,7 @@ import 'icon_button.dart'; import 'icons.dart'; import 'ink_decoration.dart'; import 'material_localizations.dart'; +import 'material_state.dart'; import 'progress_indicator.dart'; import 'theme.dart'; @@ -114,6 +115,7 @@ class PaginatedDataTable extends StatefulWidget { this.checkboxHorizontalMargin, this.controller, this.primary, + this.headingRowColor, }) : assert(actions == null || (header != null)), assert(columns.isNotEmpty), assert(sortColumnIndex == null || (sortColumnIndex >= 0 && sortColumnIndex < columns.length)), @@ -288,6 +290,9 @@ class PaginatedDataTable extends StatefulWidget { /// {@macro flutter.widgets.scroll_view.primary} final bool? primary; + /// {@macro flutter.material.dataTable.headingRowColor} + final MaterialStateProperty? headingRowColor; + @override PaginatedDataTableState createState() => PaginatedDataTableState(); } @@ -595,6 +600,7 @@ class PaginatedDataTableState extends State { showCheckboxColumn: widget.showCheckboxColumn, showBottomBorder: true, rows: _getRows(_firstRowIndex, widget.rowsPerPage), + headingRowColor: widget.headingRowColor, ), ), ), diff --git a/packages/flutter/test/material/paginated_data_table_test.dart b/packages/flutter/test/material/paginated_data_table_test.dart index 6a10073823..db7335627d 100644 --- a/packages/flutter/test/material/paginated_data_table_test.dart +++ b/packages/flutter/test/material/paginated_data_table_test.dart @@ -1264,4 +1264,33 @@ void main() { final Scrollable footerScrollView = tester.widget(find.byType(Scrollable).last); expect(footerScrollView.controller, null); }); + + testWidgets('PaginatedDataTable custom heading row color', (WidgetTester tester) async { + const MaterialStateProperty headingRowColor = MaterialStatePropertyAll(Color(0xffFF0000)); + final TestDataSource source = TestDataSource(); + + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: PaginatedDataTable( + primary: true, + header: const Text('Test table'), + source: source, + rowsPerPage: 2, + headingRowColor: headingRowColor, + columns: const [ + DataColumn(label: Text('Name')), + DataColumn(label: Text('Calories'), numeric: true), + DataColumn(label: Text('Generation')), + ], + ), + ), + ) + ); + + final Table table = tester.widget(find.byType(Table)); + final TableRow tableRow = table.children[0]; + final BoxDecoration tableRowBoxDecoration = tableRow.decoration! as BoxDecoration; + expect(tableRowBoxDecoration.color, headingRowColor.resolve({})); + }); }