Apply various filter effects in a CSS-like way in flutter, can be used on any widget, not just images, support custom filters and control filter intensity.
Package selection guidance compiled from public package information, community data, and project usage.
The css_filter package enables applying CSS-like filter effects to any Flutter widget, not just images. It supports a range of built-in filters such as blur, brightness, contrast, and saturation, with adjustable intensity. Users can also define custom filters for advanced visual effects. The package is platform-agnostic, working across Android, iOS, Web, macOS, Windows, and Linux. Ideal for enhancing UIs with dynamic visual layers without complex rendering code.
Use cases
Adding visual depth to UI elements
Creating interactive image or text effects
Enhancing app themes with dynamic filters
Designing animated transitions
Implementing photo-editing features
Building stylized user interfaces
Key features
CSS-style filter syntax
Support for any widget, not just images
Adjustable filter intensity
Custom filter definitions
Cross-platform compatibility
Real-time filter application
Suitable for
UI designers seeking visual flair
Developers building multimedia apps
Apps requiring dynamic visual effects
Prototyping interactive interfaces
Projects with rich visual storytelling
Considerations
Performance impact with heavy filters on large widgets
Limited support for complex SVG-based filters
May require optimization on lower-end devices
Filter order can affect visual outcome
Not intended for high-performance gaming graphics
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
IFstruct parser supports generating flutter code from iofod visually edited projects. We have separated its filter module code and added many preset effects to form the current CSS Filter for Flutter, which facilitates all flutter projects to use the excellent design of the Web: CSS filter.
Features
Simple and efficient
Support multiple filter effects overlay
Rich preset effects.
Full platform support
Customize your own effect
Null-safety
Getting started
After importing the dependent, you can use the basic filters through CSSFilter.
You can combine and overlay these filters in flutter just as you would with a CSS filter. Use CSSFilter.apply in conjunction with CSSFilterMatrix(). Such as:
Note: the order of the chain calls represents the order in which the filters are applied, and the order in which the filter effects are applied affects the final result.
Use presets
The CSSgram project does an excellent job of providing the CSS world with Instagram-like filters, and instagram.css complements it with more types of filters. We've combined these two libraries to encapsulate several presets that can call through CSSFilterPresets.
Similar to CSSFilter, we provide the apply method for CSSFilterPresets to invoke presets consistently, and apply additionally supports setting the intensity of the filter effect used. To do so:
/// You can replace the value parameter with any of the supported effects.CSSFilterPresets.apply(
child: YourWidget,
value: CSSFilterPresets.insNashville,
strength: 0.7
);
Customize your own filter preset
CSSFilter provides the most basic filters, CSSFilterPresets collects the commonly used combinations of basic filters as presets, meaning you can also customize your own filter presets based on the basic filters.
customPreset({ requiredWidget child }) {
returnCSSFilter.apply(
child: child,
value: CSSFilterMatrix().sepia(0.2).saturate(1.4)
);
}
/// Used by CSSFilterPresets to set the intensity of the effect.CSSFilterPresets.apply(
child: YourWidget,
value: customPreset,
strength: 0.9
);
/// It also supports direct use.customPreset(child: YourWidget);
More examples
For more usage examples, please check out the example project.