Skip to content

SyncfusionExamples/How-to-enlarge-the-tappable-area-of-a-filter-icon-in-Flutter-DataTable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How to increase the tappable area of a filter icon in Flutter DataTable?

In this article, we will show you how to increase the tappable area of filter icon in Flutter DataTable.

Initialize the SfDataGrid widget with all the necessary properties. By default, the filter icon shares space with the sort icon in the column header. To customize the filter icon, use the SfDataGridThemeData.filterIcon property. Use a builder widget to update the icon dynamically based on its state-either filtering or filtered. Wrap the icon in a SizedBox or Container and specify the desired width and height to create a tappable area for the filter icon. This ensures a clearly defined space, enabling consistent and reliable interaction with the filter popup.

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 Container(
        color: Colors.greenAccent,
        width: 40,
        height: 40,
        child: icon ??
            const Icon(
              Icons.filter_alt_off_outlined,
              size: 20,
              color: Colors.deepOrange,
            ),
      );
    },
  ),
)

You can download this example on GitHub.

About

This demo shows how to enlarge the tappable area of a filter icon in Flutter DataTable

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •