Project: Asset Icon
AssetIcon - Customizable Flutter Asset-Based Icon Package
By Hisham ยท Published on November 05, 2024
Description
AssetIcon is a powerful and customizable Flutter package for rendering asset-based icons with ease.
Whether you're working with PNG, SVG, or other formats, this package allows you to adjust properties such as size, color, and opacity.
It also offers batch generation of Dart code for your asset keys, making it easier to manage large sets of icons.
โจ Features
๐ Multiple Format Support: Display PNG and SVG icons seamlessly, along with support for other formats.
๐จ Customization: Modify icon size, color, and opacity to fit your app's theme.
๐ง Global Configuration: Set default path and color for consistent styling.
๐ก๏ธ Accessibility: Add semantic labels for screen readers.
๐ Automated Icon Key Generation: Generate constant keys for all icons in your assets folder.
๐ฆ Installation
Add AssetIcon to your pubspec.yaml
:
dependencies:
assets_icon: ^latest_version
๐ป Code Generation
Run the generator with:
dart run asset_icon:generate --source-dir assets/icons/ --class-name MyAssetIcons --output-dir lib/generated --output-file my_icons.g.dart
๐ Example Folder Structure
assets/
โโโ icons/
โโโ example_icon.png
โโโ example_icon.svg
โโโ other_icon.png
๐ค Contribute
Submit issues or pull requests to improve functionality.
๐ License
MIT License
Challenges
Managing icons in Flutter projects often becomes complicated when:
Working with many files spread across directories.
Needing SVG support (not available in ImageIcon).
Adjusting opacity or accessibility labels.
Maintaining consistency without constants for asset paths.
Solutions
AssetIcon solves these problems by:
โ Supporting both PNG and SVG formats.
โ Allowing customization of size, color, and opacity.
โ Adding semantic labels for accessibility.
โ Providing automated code generation for icon keys, ensuring consistency across the app.