Releases: cr1992/FlutterAssetsGenerator
Releases · cr1992/FlutterAssetsGenerator
3.3.0 release
[3.3.0]
Added / 新增
leaf_typesupports both styles:leaf_typeis now independent ofstyle. Legacy mode can useleaf_type: classto get typed wrappers (AssetGenImage,SvgGenImage, etc.) with flat access paths. Default:classfor robust,stringfor legacy.leaf_type支持所有风格:leaf_type不再绑定style。Legacy 模式可通过leaf_type: class获得类型安全的包装类,同时保持扁平访问路径。默认值:robust 为class,legacy 为string。
- Right-click module setup: Right-click a Flutter module root in Project View to set up that module individually.
- 右键模块配置: 在项目树中右键 Flutter 模块根目录即可单独配置该模块。
enable: falsecleanup: Disabling a module now removes its generated Dart file.- 禁用即清理: 设置
enable: false后自动删除已生成的 Dart 文件。
- 禁用即清理: 设置
Improved / 优化
- Monorepo performance: Batch generation up to ~15x faster (async flow, single Flutter version resolve, skip reformat).
- Monorepo 性能: 批量生成提速约 15 倍(异步流程、单次 Flutter 版本解析、跳过格式化)。
- Smarter module discovery: Filters out
ephemeral,.plugin_symlinksetc.; only real Flutter modules are configurable.- 更精准的模块发现: 过滤
ephemeral、.plugin_symlinks等目录,仅识别真实 Flutter 模块。
- 更精准的模块发现: 过滤
- Setup defaults:
package_parameter_enablednow defaults based on module type (app →false, package →true).- 配置默认值:
package_parameter_enabled根据模块类型自动设定(app →false,package →true)。
- 配置默认值:
FlutterAssetsGenerator 3.2.0
[3.2.0]
Added / 新增
- Enable Config: Added
enableto explicitly control whether a module participates in watching and generation.- 启用开关: 新增
enable配置,用于显式控制模块是否参与监听和生成。
- 启用开关: 新增
- Leaf Type Config: Added
leaf_typeforrobuststyle so hierarchical APIs can return either typed wrappers or rawStringpaths.- 叶子类型配置: 为
robust风格新增leaf_type配置,支持在保留分层 API 的同时选择返回包装类型或原始String路径。
- 叶子类型配置: 为
Changed / 变更
- YAML Source of Truth: 3.x now treats
pubspec.yamlas the source of truth. Modules without aflutter_assets_generatorblock are no longer watched or generated automatically.- YAML 单一配置源: 3.x 以后统一以
pubspec.yaml为准。未配置flutter_assets_generator的模块不再自动监听或生成。
- YAML 单一配置源: 3.x 以后统一以
Fixed / 修复
- Name Style Handling: Fixed
name_stylehandling so generated identifiers now consistently respectcamelandsnake.- 命名风格处理: 修复
name_style配置未被完整应用的问题,确保生成标识符稳定遵循camel和snake。
- 命名风格处理: 修复
- Legacy Naming Compatibility: Restored legacy flat naming behavior for numeric assets such as
assets/images/0.png -> Assets.images0.- Legacy 命名兼容: 恢复旧版扁平命名在数字资源下的兼容行为,例如
assets/images/0.png -> Assets.images0。
- Legacy 命名兼容: 恢复旧版扁平命名在数字资源下的兼容行为,例如
- Robust Directory Naming: Directory helper classes now use the full physical asset path to avoid collisions when different roots share the same folder name or tree shape.
- Robust 目录命名: 目录内部类改为基于完整物理路径生成,修复不同资源根目录同名或同结构目录发生冲突的问题。
- Robust Root Flattening: Root flattening now only applies to a single
assets/root so intermediate directories remain stable in deep paths.- Robust 根目录扁平化: 根目录扁平化现在仅对单一
assets/根生效,避免深层路径丢失中间目录。
- Robust 根目录扁平化: 根目录扁平化现在仅对单一
3.1.0 bug fix & new feature
[3.1.0]
Added / 新增
- Legacy Naming: Added
named_with_parentoption forlegacystyle to restore old directory-prefixed variable naming (e.g.,imagesBtnLogo).- 遗留命名兼容: 为
legacy风格新增named_with_parent配置项,彻底还原旧版的带目录前缀变量名生成逻辑 (例如imagesBtnLogo)。
- 遗留命名兼容: 为
- Rive Support: Added support for
.rivefiles andrivedependency automation.- Rive 支持: 新增对
.rive文件及rive依赖自动化的支持。
- Rive 支持: 新增对
- Submodule Support: Fixed
flutter pub getexecution context for submodules.- 子模块支持: 修复了子模块中
flutter pub get的执行上下文问题,确保在正确的目录执行。
- 子模块支持: 修复了子模块中
- Auto Dependencies Config: Added
auto_add_dependenciesconfig to control automatic dependency injection.- 自动依赖配置: 新增
auto_add_dependencies配置,用于控制是否自动添加依赖。
- 自动依赖配置: 新增
Fixed / 修复
- Diacritic Handling: Automatically remove diacritics from filenames to generate valid ASCII Dart variable names (e.g.,
crème->creme).- 变音符号处理: 自动移除文件名中的变音符号,确保生成合法的 ASCII Dart 变量名 (例如
crème->creme)。
- 变音符号处理: 自动移除文件名中的变音符号,确保生成合法的 ASCII Dart 变量名 (例如
3.0.0
[3.0.0]
BREAKING CHANGES / 重大变更
- Default Generation Style: The default generated code is now hierarchical (e.g.,
Assets.images.logo) instead of flat. To restore the old flat behavior, addstyle: legacyto yourpluginconfig inpubspec.yaml.- 默认生成风格: 默认生成的代码现在是 分层级 的 (例如
Assets.images.logo) 而不是扁平的。如果需要恢复旧版的扁平风格,请在pubspec.yaml配置中添加style: legacy。
- 默认生成风格: 默认生成的代码现在是 分层级 的 (例如
Added / 新增
- Multi-Module Support: Complete isolation for config per module/project.
- 多模块支持: 实现模块/项目级别的配置完全隔离,互不干扰。
- Legacy Compatibility: Added
styleoption (robustvslegacy) to support legacy flat generation style.- 旧版兼容: 新增
style选项 (robust或legacy),支持恢复旧版的扁平生成风格。
- 旧版兼容: 新增
- Safe Generation: Moved generation logic to
invokeLaterto prevent file locking issues.- 安全生成: 将生成逻辑移至
invokeLater执行,彻底解决文件锁冲突问题。
- 安全生成: 将生成逻辑移至
- Auto Format: Restored automatic code formatting for generated files.
- 自动格式化: 恢复了生成代码的自动格式化功能。
- Package Parameter Support: Added
package_parameter_enabledoption to generate assets withpackageparameter, enabling usage across modules.- Package 参数支持: 新增
package_parameter_enabled选项,支持生成带package参数的资源引用,方便在多模块中跨包使用。
- Package 参数支持: 新增
Changed / 变更
- Smart Trigger: Configuration changes now trigger on File Save (Cmd+S) instead of typing, reducing unnecessary builds.
- 智能触发: 配置文件变更现在通过 保存文件 (Cmd+S) 触发,而不是在键入时频繁触发,减少冗余构建。
- Config Reading: Prioritize reading from Editor Memory (Document) over Disk to prevent stale data issues.
- 配置读取: 优先从编辑器内存 (Document) 读取配置,防止因磁盘写入延迟导致的旧数据问题。
- Refined Naming: Unified special character handling for asset filenames across all modes.
- 命名优化: 统一了所有模式下资源文件名的特殊字符处理逻辑,确保生成的变量名始终合法。
Fixed / 修复
- Notification Group: Fixed duplicate
NotificationGroupregistration warning by using singleton pattern.- 通知组: 使用单例模式修复了重复注册警告。
- Redundant Generation: Prevented unnecessary code regeneration after dependency injection by ignoring dependency version changes in config comparison.
- 重复生成: 通过在配置比较中忽略依赖版本变化,防止依赖注入后的不必要代码重新生成。
Improved / 性能优化
- Flutter Version Detection: Implemented 3-tier caching mechanism (Cache > File > Command) for version detection.
- Flutter 版本检测: 实施三级缓存机制 (缓存 > 文件 > 命令),大幅提升检测速度。
- Performance: 60x faster on first call (~10ms vs ~600ms), 600x faster on subsequent calls (<1ms vs ~600ms)
- 性能提升: 首次调用快 60 倍 (~10ms vs ~600ms),后续调用快 600 倍 (<1ms vs ~600ms)
- Eliminated Flutter command lock conflicts
- 消除了 Flutter 命令锁冲突
- Supports Puro and other third-party Flutter management tools
- 支持 Puro 等第三方 Flutter 管理工具