From 9f898ffef789453ed74cfae7fe9662437c0b3032 Mon Sep 17 00:00:00 2001 From: Chinmoy Date: Tue, 4 May 2021 01:01:48 +0530 Subject: [PATCH] Added arrowHeadColor property to PaginatedDataTable (#81393) --- .../src/material/paginated_data_table.dart | 12 +++++--- .../material/paginated_data_table_test.dart | 28 +++++++++++++++++++ 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/packages/flutter/lib/src/material/paginated_data_table.dart b/packages/flutter/lib/src/material/paginated_data_table.dart index b49cd51f9e..a8117d0940 100644 --- a/packages/flutter/lib/src/material/paginated_data_table.dart +++ b/packages/flutter/lib/src/material/paginated_data_table.dart @@ -84,6 +84,7 @@ class PaginatedDataTable extends StatefulWidget { this.availableRowsPerPage = const [defaultRowsPerPage, defaultRowsPerPage * 2, defaultRowsPerPage * 5, defaultRowsPerPage * 10], this.onRowsPerPageChanged, this.dragStartBehavior = DragStartBehavior.start, + this.arrowHeadColor, required this.source, this.checkboxHorizontalMargin, }) : assert(actions == null || (actions != null && header != null)), @@ -235,6 +236,9 @@ class PaginatedDataTable extends StatefulWidget { /// and the content in the first data column. This value defaults to 24.0. final double? checkboxHorizontalMargin; + /// Defines the color of the arrow heads in the footer. + final Color? arrowHeadColor; + @override PaginatedDataTableState createState() => PaginatedDataTableState(); } @@ -442,27 +446,27 @@ class PaginatedDataTableState extends State { Container(width: 32.0), if (widget.showFirstLastButtons) IconButton( - icon: const Icon(Icons.skip_previous), + icon: Icon(Icons.skip_previous, color: widget.arrowHeadColor), padding: EdgeInsets.zero, tooltip: localizations.firstPageTooltip, onPressed: _firstRowIndex <= 0 ? null : _handleFirst, ), IconButton( - icon: const Icon(Icons.chevron_left), + icon: Icon(Icons.chevron_left, color: widget.arrowHeadColor), padding: EdgeInsets.zero, tooltip: localizations.previousPageTooltip, onPressed: _firstRowIndex <= 0 ? null : _handlePrevious, ), Container(width: 24.0), IconButton( - icon: const Icon(Icons.chevron_right), + icon: Icon(Icons.chevron_right, color: widget.arrowHeadColor), padding: EdgeInsets.zero, tooltip: localizations.nextPageTooltip, onPressed: _isNextPageUnavailable() ? null : _handleNext, ), if (widget.showFirstLastButtons) IconButton( - icon: const Icon(Icons.skip_next), + icon: Icon(Icons.skip_next, color: widget.arrowHeadColor), padding: EdgeInsets.zero, tooltip: localizations.lastPageTooltip, onPressed: _isNextPageUnavailable() diff --git a/packages/flutter/test/material/paginated_data_table_test.dart b/packages/flutter/test/material/paginated_data_table_test.dart index 2d862e939e..1719f6bb42 100644 --- a/packages/flutter/test/material/paginated_data_table_test.dart +++ b/packages/flutter/test/material/paginated_data_table_test.dart @@ -974,4 +974,32 @@ void main() { await binding.setSurfaceSize(null); }); + + testWidgets('PaginatedDataTable arrowHeadColor set properly', (WidgetTester tester) async { + await binding.setSurfaceSize(const Size(800, 800)); + const Color arrowHeadColor = Color(0xFFE53935); + + await tester.pumpWidget( + MaterialApp( + home: PaginatedDataTable( + arrowHeadColor: arrowHeadColor, + showFirstLastButtons: true, + header: const Text('Test table'), + source: TestDataSource(), + columns: const [ + DataColumn(label: Text('Name')), + DataColumn(label: Text('Calories'), numeric: true), + DataColumn(label: Text('Generation')), + ], + ), + ) + ); + + final Iterable icons = tester.widgetList(find.byType(Icon)); + + expect(icons.elementAt(0).color, arrowHeadColor); + expect(icons.elementAt(1).color, arrowHeadColor); + expect(icons.elementAt(2).color, arrowHeadColor); + expect(icons.elementAt(3).color, arrowHeadColor); + }); }