Pass showCheckboxColumn parameter to DataTable (#53655)
This commit is contained in:
@@ -474,6 +474,7 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
|
||||
headingRowHeight: widget.headingRowHeight,
|
||||
horizontalMargin: widget.horizontalMargin,
|
||||
columnSpacing: widget.columnSpacing,
|
||||
showCheckboxColumn: widget.showCheckboxColumn,
|
||||
rows: _getRows(_firstRowIndex, widget.rowsPerPage),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -726,4 +726,27 @@ void main() {
|
||||
// Reset the surface size.
|
||||
await binding.setSurfaceSize(originalSize);
|
||||
});
|
||||
|
||||
testWidgets('PaginatedDataTable with optional column checkbox', (WidgetTester tester) async {
|
||||
await binding.setSurfaceSize(const Size(800, 800));
|
||||
|
||||
Widget buildTable(bool checkbox) => MaterialApp(
|
||||
home: PaginatedDataTable(
|
||||
header: const Text('Test table'),
|
||||
source: TestDataSource(onSelectChanged: (bool value) {}),
|
||||
showCheckboxColumn: checkbox,
|
||||
columns: const <DataColumn>[
|
||||
DataColumn(label: Text('Name')),
|
||||
DataColumn(label: Text('Calories'), numeric: true),
|
||||
DataColumn(label: Text('Generation')),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(buildTable(true));
|
||||
expect(find.byType(Checkbox), findsNWidgets(11));
|
||||
|
||||
await tester.pumpWidget(buildTable(false));
|
||||
expect(find.byType(Checkbox), findsNothing);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user