The code generator for the Iconify SDK. Automatically bundles icons into type-safe Dart constants for 100% offline production builds.
This package is a build_runner extension that scans your Flutter source code for IconifyIcon(...) usages. It resolves the required icon data from your local snapshots and generates a lib/icons.g.dart file.
Add the builder to your dev_dependencies:
dev_dependencies:
iconify_sdk_builder: ^1.0.1
build_runner: ^2.4.0Run the build command:
dart run build_runner buildThe builder will look for an iconify.yaml file in your project root to determine where your local icon snapshots are stored and where to write the generated code.
sets:
- mdi:*
- lucide:rocket
data_dir: assets/iconify
output: lib/icons.g.dart- Scanning: It uses a hybrid AST + Regex scanner to find icon identifiers like
'mdi:home'in your.dartfiles. - Resolution: It searches your
data_dirfor the corresponding Iconify JSON snapshots. - Generation: It produces a type-safe Dart file containing only the icons you've actually used, ensuring zero-waste bundles.
- Literal Strings Only: The scanner currently only detects icons passed as literal strings (e.g.,
IconifyIcon('mdi:home')). It cannot detect icons assigned to variables or constructed dynamically at runtime.
This project is licensed under the MIT License. See the LICENSE file for details.