flutter 相关之添加图片

本文档介绍了在Windows和Ubuntu上为Flutter项目添加图片的步骤。在Windows上,涉及创建图片目录、更新`pubspec.yaml`和`main.dart`文件。在Ubuntu上,虽然过程相同,但遇到.jpg图片无法显示的问题,转换为.png格式后问题解决,具体原因待查。
摘要由CSDN通过智能技术生成

flutter添加图片在win和linux上

【环境】
1、win子系统ubuntu18.04
2、ubuntu下flutter版本1.22.4
3、xrdp 远程桌面


1、win10
2、win10下flutter版本1.24.0.10-1.pre

一、win上添加

1、创建图片存放目录

mkdir images
tree -L 1
├── README.md
├── android
├── build
├── has-anmimation-bak-main.dart-txt.txt
├── images
├── ios
├── lib
├── linux
├── pubspec.lock
├── pubspec.yaml
├── test
└── textdisplay.iml

images文件名可以随意设置

2、修改文件pubspec.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:
    - images/1.jpg
  #   - images/a_dot_ham.jpeg
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值