flutter plugins插件【二】【FlutterAssetsGenerator】

2、FlutterAssetsGenerator

flutter plugins插件【二】【FlutterAssetsGenerator】_第1张图片

介绍地址: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名字参数

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

flutter plugins插件【二】【FlutterAssetsGenerator】_第2张图片

你可能感兴趣的:(AssetsGenerator,Flutter)