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)