【问题标题】:Flutter Image not displaying颤振图像不显示
【发布时间】:2022-01-08 09:27:15
【问题描述】:

我在资产文件夹/图像上添加了图像。所以我正在尝试制作一个带有图像横幅的页面,这是我的代码:

Container(
          height: 120,
          decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(10.0),
            image: const DecorationImage(
              image: AssetImage("assets/images/drive.png"),
              fit: BoxFit.fill,
            ),
          ),
        ),



# To add assets to your application, add an assets section, like this:

资产: - 资产/图像/

- 图像/a_dot_ham.jpeg

【问题讨论】:

  • 尝试重新运行应用加载图片
  • 运行 flutter pub get 命令,然后重新运行应用程序。

标签: flutter image display provider


【解决方案1】:

确保您项目中的图片扩展名与您在资产文件夹中添加的图片完全相同。 (.jpeg、.jpg 或 .png) 必须检查 pubspec 文件。然后在 pubspec 文件中运行一次 pub get 命令。您仍然无法在您的应用中看到图像,然后转到 File -> Invalidate Caches / Restart。

(您也可以使用 Image.asset 代替 AssetImage。)

【讨论】:

    猜你喜欢
    • 2019-08-30
    • 2020-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-03
    • 2021-05-07
    相关资源
    最近更新 更多