The filter icon in Flutter is a built-in Material Design icon, accessed as Icons.filter_list (or Icons.filter_alt for a slightly different look), and you display it with an Icon widget or as the icon property of an IconButton, FloatingActionButton, or similar. For example, IconButton(icon: Icon(Icons.filter_list), onPressed: () {}) places a tappable filter icon in your app bar or anywhere else in your UI.
What the Filter Icon Looks Like in Flutter
Flutter ships with the Material Icons font, which includes several filter-related glyphs. The most common are:
Icons.filter_list– the classic funnel shape with three horizontal lines, used widely for filtering lists.Icons.filter_alt– a funnel with a stem, often used in newer Material Design contexts.Icons.filter_alt_outlined– the outlined version offilter_alt.Icons.filter_alt_roundedandIcons.filter_alt_sharp– themed variants that adapt to the app’s icon theme.Icons.filter– a different funnel shape, less commonly used for filtering actions.
All of these are part of the Icons class in the material library, so you don’t need any extra packages. The exact visual appearance depends on the device’s font rendering and the ThemeData.iconTheme you set.
How to Add a Filter Icon to Your UI
Adding a filter icon is straightforward. Here are the most common ways:
- As a plain icon:
Icon(Icons.filter_list, size: 24, color: Colors.grey)– useful when you want to show the icon without interaction. - As an icon button:
IconButton(icon: Icon(Icons.filter_list), onPressed: () { _openFilterDialog(); })– the standard for tappable icons. - In an app bar action: Add the
IconButtontoAppBar.actions. - In a FloatingActionButton:
FloatingActionButton(child: Icon(Icons.filter_alt), onPressed: ...)– less common but possible. - In a dropdown or menu: Use it as a leading icon in a
ListTileorPopupMenuButton.
You can also combine it with a badge to show that a filter is active, using the Badge widget (available from Flutter 3.7 onwards) or a third-party package.
Filtering Data: What the Icon Usually Does
The icon itself is just a visual; the logic behind it is up to you. In a typical Flutter app, tapping a filter icon opens a bottom sheet, a dialog, or a dedicated screen where users select criteria. Then you apply those criteria to your data list using methods like where() on a collection. For example:
List<Item> filteredItems = allItems.where((item) => item.category == selectedCategory).toList();
Many apps also show a small dot or a number on the icon to indicate that filters are active. You can achieve this by wrapping the icon in a Stack with a Positioned container.
Choosing Between filter_list and filter_alt
Both icons are valid, but they convey slightly different meanings. filter_list is the older, more familiar funnel with lines – it’s what most users associate with “filter” in Material Design. filter_alt is a more modern, streamlined funnel without lines, often used in dense interfaces. If you’re following Material 3 guidelines, filter_alt is more common in newer apps, but there’s no strict rule. Pick one and stay consistent across your app. You can also use the outlined variant to match an outlined icon style elsewhere.
Common Problems and How to Fix Them
Here are a few issues you might run into:
- Icon not showing: Make sure you have the
materialpackage imported (it is by default in a standard Flutter project). If you’re using a custom font, the icon font might be missing – but that’s rare. - Icon too small or too large: Adjust the
sizeproperty of theIconwidget. The default is 24, but you can set any value. - Icon not tappable: If you use
Iconalone, it won’t respond to taps. Wrap it inIconButtonorGestureDetector. - Icon color not changing: The color is controlled by
ThemeData.iconThemeor thecolorproperty on theIconwidget. If you set a color on theIconButton, it overrides the icon color. - Filter icon in a TextField: If you want a filter icon inside a text field’s suffix or prefix, use
InputDecoration(suffixIcon: Icon(Icons.filter_list)).
Filter Icon vs. Search Icon: When to Use Which
Users often confuse filter and search icons. The search icon (Icons.search) is a magnifying glass and implies free-text querying. The filter icon implies narrowing down a set of results using predefined criteria (categories, dates, price ranges). In practice, many apps combine both: a search bar for text, and a filter icon to open advanced options. If you only have one action, think about what the user expects – if they can type, use search; if they need to select from options, use filter.
Accessibility and Localization Tips
For accessibility, always provide a semantic label to the icon so screen readers announce it correctly. In an IconButton, set the tooltip property:
IconButton(
icon: Icon(Icons.filter_list),
tooltip: 'Filter',
onPressed: ...
)
For localization, use MaterialLocalizations or your own strings to translate the tooltip. The icon itself is language-neutral, so no changes are needed for different locales.
Frequently Asked Questions
How do I change the color of the filter icon?
Set the color property on the Icon widget, or on the IconButton if you’re using one. For example, Icon(Icons.filter_list, color: Colors.red).
Can I use a custom filter icon instead of the built-in one?
Yes. You can use any IconData from a package like FontAwesome or MaterialIcons (the built-in set), or use a custom SVG image with ImageIcon or SvgPicture from the flutter_svg package.
Is there a way to show a badge on the filter icon?
Yes. Wrap the icon in a Stack and add a small Container with a circle shape at the top-right corner. Alternatively, use the Badge widget that Flutter provides since version 3.7.
Why does my filter icon look different on Android and iOS?
Flutter uses the same Material font on both platforms, so the icon itself is identical. Differences may come from the surrounding theme (e.g., app bar color, icon size) or from platform-specific font rendering. To ensure consistency, set an explicit size and color.
How do I make the filter icon open a bottom sheet?
Call showModalBottomSheet inside the onPressed callback. For example: showModalBottomSheet(context: context, builder: (context) => YourFilterSheet()).
Can I use the filter icon in a DataTable header?
Yes. Place an IconButton with the filter icon in a DataColumn’s label, or in a custom header widget. The icon will work the same as anywhere else.