You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Flutter项目中添加资源图片?

从资源文件夹添加图片的步骤
  • 创建一个名为assets的文件夹(你可以自定义名称,但推荐使用assets)
  • 在pubspec.yaml文件中注册你的资源文件夹及其中的图片
  • 使用以下代码来显示资源文件夹中的图片:
Image(
  image: AssetImage(
    'assets/car.jpg',
  ),
  fit: BoxFit.fitHeight,
),

内容的提问来源于stack exchange,提问作者azeem

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.10 06:15:38