Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Flutter, how do I change the color of the sorting icon?

Widget DataTable has an built-in icon for sorting indication

enter image description here

How can I change the color or even the icon?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

                Scrollbar(
                  controller: _scrollController,
                  child: SingleChildScrollView(
                    controller: _scrollController,
                    scrollDirection: Axis.horizontal,
                      child: DataTable(
                      border: TableBorder.all(width: 0.2),
                      headingRowColor: MaterialStateProperty.resolveWith<Color?>(
                          (Set<MaterialState> states) {
                        return Styles.TableHeaderColor;
                      }),
                      columns: getColumns(TableTitles),
                      rows: getRows(),
                      sortColumnIndex: sortColumnIndex,
                      sortAscending: isAscending,
                      dataRowHeight: 50,
                      headingRowHeight: 40,
                    ),
                  ),
                ),

>Solution :

The icon use the IconThemeData, so either change that for the entire app, or for the specific widget. I.e. you can wrap your DataTable in a Theme widget, something like this:

final theme = Theme.of(context);
...
Theme(
 data: theme.copyWith(iconTheme: theme.iconTheme.copyWith(color: Colors.red)),
  child: DataTable(...)
),
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading