filterIcon property

Widget? filterIcon
final

The icon to indicate the filtering applied in column.

If you want to change the icon filter or filtered state, you can use the Builder widget and return the respective icon for the state. You have to return the icons for both the states even if you want to change the icon for specific state.

@override
Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar(
      title: const Text('Syncfusion Flutter DataGrid',
          overflow: TextOverflow.ellipsis),
    ),
    body: SfDataGridTheme(
      data: SfDataGridThemeData(filterIcon: Builder(
        builder: (context) {
          Widget? icon;
          String columnName = '';
          context.visitAncestorElements((element) {
            if (element is GridHeaderCellElement) {
              columnName = element.column.columnName;
            }
            return true;
          });
          var column = _employeeDataSource.filterConditions.keys
              .where((element) => element == columnName)
              .firstOrNull;
          if (column != null) {
            icon = const Icon(
              Icons.filter_alt_outlined,
              size: 20,
              color: Colors.purple,
            );
          }
          return icon ??
              const Icon(
                Icons.filter_alt_off_outlined,
                size: 20,
                color: Colors.deepOrange,
              );
        },
      )),
      child: SfDataGrid(
        source: _employeeDataSource,
        allowFiltering: true,
        allowSorting: true,
        columns: getColumns(),
      ),
    ),
  );
}

Implementation

///           if (column != null) {
///             icon = const Icon(
///               Icons.filter_alt_outlined,
///               size: 20,
///               color: Colors.purple,
///             );
///           }
///           return icon ??
///               const Icon(
///                 Icons.filter_alt_off_outlined,
///                 size: 20,
///                 color: Colors.deepOrange,
///               );
///         },
///       )),
///       child: SfDataGrid(
///         source: _employeeDataSource,
///         allowFiltering: true,
///         allowSorting: true,
///         columns: getColumns(),
///       ),
///     ),
///   );
/// }
/// ```
final Widget? filterIcon;