A Dart code generator package to produce Flutter Material Icon mappings using build_runner. This tool enables automated generation of icon code point to name mappings, making it ideal for Flutter applications that require icon metadata at runtime or during development.
- 🔧 Automatically extracts
IconDatamappings from Flutter'sicons.dart - ⇁ Generates code for bidirectional mapping between icon names and code points
- 🔌 Seamless integration with
build_runnerworkflows
Add the following to your pubspec.yaml:
dependencies:
flutter:
sdk: flutter
dev_dependencies:
icon_data_generator:
git:
url: https://github.com/your-org/icon_data_generator.git
build_runner: latest_versionRun the code generation command:
flutter pub run build_runner buildThis will generate:
lib/icon_maps/material_icons_mapper.g.dartlib/icon_maps/material_icon_data_map.g.dart
These files contain:
- A
Map<int, String>for code point to icon name resolution - A
Map<String, int>for icon name to code point resolution
// material_icons_mapper.g.dart
const Map<int, String> iconCodePointToName = {
57344: 'ten_k',
59136: 'ten_k_sharp',
62687: 'ten_k_rounded',
60914: 'ten_k_outlined',
// ... more icons
};
const Map<String, int> iconNameToCodePoint = {
'ten_k': 57344,
'ten_k_sharp': 59136,
'ten_k_rounded': 62687,
'ten_k_outlined': 60914,
// ... more icons
};Ideal for:
- Icon pickers
- Runtime icon inspection
- Custom UI rendering based on icon metadata
MIT License
This package is maintained by Shohidul Islam.
Pull requests and issues are welcome! Please run:
dart format .
flutter pub run build_runner build --delete-conflicting-outputsbefore submitting a PR.