Unverified Commit 69f61a28 authored by Salmanul Farisi.M's avatar Salmanul Farisi.M Committed by GitHub

added option to change color of heading row(flutter#132428) (#132728)

Paginated datatable widget cannot give color to table header
 
fixes #132428

---------
Co-authored-by: 's avatarHans Muller <hansmuller@google.com>
parent 2ea52966
......@@ -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<Color?>? headingRowColor;
@override
PaginatedDataTableState createState() => PaginatedDataTableState();
}
......@@ -595,6 +600,7 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
showCheckboxColumn: widget.showCheckboxColumn,
showBottomBorder: true,
rows: _getRows(_firstRowIndex, widget.rowsPerPage),
headingRowColor: widget.headingRowColor,
),
),
),
......
......@@ -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<Color> headingRowColor = MaterialStatePropertyAll<Color>(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>[
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(<MaterialState>{}));
});
}
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