欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

flutter image加载本地图片

程序员文章站 2022-07-15 15:53:49
...
  • 项目中创建assets文件夹,图片拖放到文件夹中。
  • pubspect.yaml文件中,添加图片路径:
# The following section is specific to Flutter.
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/1.png
     - assets/2.png

注意: assets:前不要有空格,否则报错。

  • 引用本地图片:
new Image.asset('assets/1.png'),
new Image.asset('assets/2.png'),