flutter plugins插件【二】【FlutterAssetsGenerator】

2、FlutterAssetsGenerator

介绍地址:https://juejin.cn/post/6898542896274735117

配置assets目录

​ 插件会从pubspec.yaml文件下读取assets目录,因此要使用本插件,你需要在pubspec.yaml下配置资源目录

复制代码
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  assets:
    - assets/images/

注意1:图片拖动或者粘贴到asstes/images/目录下就会触发在指定文件自动生成对应的图片路径

复制代码
Image.asset(
  Assets.imagesAdd,
  width: 40,
  height: 40,
)

注意2:如果是在module中用这个插件,需要增加传递module名字参数

手动触发生成图片路径操作如下

相关推荐
jump_jump8 小时前
GetX — Flutter 的瑞士军刀,还是过度封装的陷阱?
flutter·设计模式·前端框架
MonkeyKing17 小时前
三棵树彻底拆解(Widget / Element / RenderObject)
flutter·dart
Lanren的编程日记19 小时前
Flutter 鸿蒙应用错误处理优化实战:完善全局异常捕获,全方位提升应用稳定性
flutter·华为·harmonyos
Lanren的编程日记19 小时前
Flutter鸿蒙应用开发:网络请求优化实战,全方位提升请求稳定性与性能
网络·flutter·harmonyos
IntMainJhy20 小时前
【futter for open harmony】Flutter 鸿蒙聊天应用实战:shared_preferences 本地键值存储适配指南[特殊字符]
flutter·华为·harmonyos
IntMainJhy20 小时前
【Flutter for OpenHarmony 】第三方库鸿蒙电商实战|首页模块完整实现[特殊字符]
flutter·华为·harmonyos
梦想不只是梦与想20 小时前
flutter 与原生通信的底层原理(二)
flutter
Lanren的编程日记21 小时前
Flutter 鸿蒙应用离线模式实战:无网络也能流畅使用
网络·flutter·harmonyos
IntMainJhy21 小时前
【Flutter for OpenHarmony 】第三方库 聊天应用:Provider 状态管理实战指南
flutter·华为·harmonyos