Skip to content

Commit 48b0716

Browse files
authored
Added ability to customize sort icon color (#354)
Looks good, thx!
1 parent dee6a1d commit 48b0716

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

lib/src/async_paginated_data_table_2.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ class AsyncPaginatedDataTable2 extends PaginatedDataTable2 {
326326
super.sortAscending = true,
327327
super.sortArrowAnimationDuration = const Duration(milliseconds: 150),
328328
super.sortArrowIcon = Icons.arrow_upward,
329+
super.sortArrowIconColor,
329330
super.sortArrowAlwaysVisible,
330331
super.sortArrowBuilder,
331332
super.onSelectAll,

lib/src/data_table_2.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ class DataTable2 extends DataTable {
185185
this.lmRatio = 1.2,
186186
this.sortArrowAnimationDuration = const Duration(milliseconds: 150),
187187
this.sortArrowIcon = Icons.arrow_upward,
188+
this.sortArrowIconColor,
188189
this.sortArrowBuilder,
189190
this.headingRowDecoration,
190191
required super.rows,
@@ -234,6 +235,9 @@ class DataTable2 extends DataTable {
234235
/// When set always overrides/preceeds default arrow icons.
235236
final IconData sortArrowIcon;
236237

238+
/// When set always overrides/preceeds default arrow icon color.
239+
final Color? sortArrowIconColor;
240+
237241
/// A builder for the sort arrow widget. Can be used in combination with [sortArrowAlwaysVisible] for a custom
238242
/// sort arrow behavior. If this is used [sortArrowIcon], [sortArrowAnimationDuration] will be ignored.
239243
final Widget? Function(bool ascending, bool sorted)? sortArrowBuilder;
@@ -435,6 +439,7 @@ class DataTable2 extends DataTable {
435439
up: sorted ? ascending : null,
436440
duration: sortArrowAnimationDuration,
437441
sortArrowIcon: sortArrowIcon,
442+
sortArrowIconColor: sortArrowIconColor,
438443
),
439444
const SizedBox(width: _sortArrowPadding),
440445
],
@@ -1444,6 +1449,7 @@ class _SortArrow extends StatefulWidget {
14441449
required this.up,
14451450
required this.duration,
14461451
required this.sortArrowIcon,
1452+
this.sortArrowIconColor,
14471453
});
14481454

14491455
final bool visible;
@@ -1454,6 +1460,8 @@ class _SortArrow extends StatefulWidget {
14541460

14551461
final IconData sortArrowIcon;
14561462

1463+
final Color? sortArrowIconColor;
1464+
14571465
@override
14581466
_SortArrowState createState() => _SortArrowState();
14591467
}
@@ -1558,6 +1566,7 @@ class _SortArrowState extends State<_SortArrow> with TickerProviderStateMixin {
15581566
alignment: Alignment.center,
15591567
child: Icon(
15601568
widget.sortArrowIcon,
1569+
color: widget.sortArrowIconColor,
15611570
size: _arrowIconSize,
15621571
),
15631572
),

lib/src/paginated_data_table_2.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ class PaginatedDataTable2 extends StatefulWidget {
166166
this.sortAscending = true,
167167
this.sortArrowAnimationDuration = const Duration(milliseconds: 150),
168168
this.sortArrowIcon = Icons.arrow_upward,
169+
this.sortArrowIconColor,
169170
this.sortArrowBuilder,
170171
this.sortArrowAlwaysVisible = false,
171172
this.onSelectAll,
@@ -272,6 +273,9 @@ class PaginatedDataTable2 extends StatefulWidget {
272273
/// If not set, the default icon is [Icons.arrow_upward]
273274
final IconData sortArrowIcon;
274275

276+
/// You can customize the icon color by setting [sortArrowIconColor].
277+
final Color? sortArrowIconColor;
278+
275279
/// This used in combination with [sortArrowBuilder] to create a custom sort arrow widget behavior.
276280
/// If this is set to true the [sortArrowBuilder] will run for all columns that have [onSort] != null.
277281
final bool sortArrowAlwaysVisible;
@@ -772,6 +776,7 @@ class PaginatedDataTable2State extends State<PaginatedDataTable2> {
772776
sortColumnIndex: widget.sortColumnIndex,
773777
sortAscending: widget.sortAscending,
774778
sortArrowIcon: widget.sortArrowIcon,
779+
sortArrowIconColor: widget.sortArrowIconColor,
775780
sortArrowAnimationDuration: widget.sortArrowAnimationDuration,
776781
sortArrowBuilder: widget.sortArrowBuilder,
777782
onSelectAll: widget.onSelectAll,

0 commit comments

Comments
 (0)