梦书之家(移动开发)

你有一个苹果,我有一个苹果,我们交换一下,一人还是一个苹果;你有一个思想,我有一个思想,我们交换一下,一人就有两个思想。 ——肖伯纳

导航

Flutter之Image

本地图片加载,需要先在 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 Flutter specific assets to your application, add an assets section,
  # like this:
  # assets:
  #  - images/a_dot_burr.jpeg
  #  - images/a_dot_ham.jpeg

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.io/assets-and-images/#resolution-aware.

  # For details regarding adding assets from package dependencies, see
  # https://flutter.io/assets-and-images/#from-packages
  assets:
    - images/arrow_downward.png

需要特别注意的就是:

1) assets前面必须有两个空格。否则会导致无法加载本地图片,难以定位

2)文件包含扩展名(如png)

 

posted on 2019-11-28 10:52  梦书  阅读(280)  评论(0编辑  收藏  举报