android - 无法在颤动中加载资产(图像)
问题描述
Aight people 这是我第一次这样做,所以我会尽量做到精确和整洁......
所以我刚刚开始学习颤振,我正在观看关于它的课程,但是在复制教练输入的内容时,每当我尝试在我的虚拟或物理设备上运行此代码时,我偶然发现了这个问题,它不会加载图片。我检查了 pubsec.yaml 文件,一切似乎都工作正常,但图像没有加载。顺便说一句,我正在使用最新版本的 AndroidStudio(我猜是金丝雀)。在此先感谢,我希望有人能帮助我。这是代码:
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: Colors.blueGrey,
appBar: AppBar(
title: Center(
child: Text('I am rich.'),
),
backgroundColor: Colors.blueGrey[900],
),
body: Center(
child: Image(
image: AssetImage('diamond.png'),
),
),
),
),
);
}
这是代码中图片的下载链接: https ://drive.google.com/uc?export=download&id=1IA7othwL6jGtvc1Wfyj0K6hxrEH9OHam
解决方案
您是否将图像的路径放在pubspec.yaml
? 为了让 Flutter 识别你的资产图片,你需要把他的路径放在pubspec.yaml
你的项目文件中。
推荐阅读
- jenkins-job-dsl - Jenkins DSL Plugin (>=1.77): 在 pipelineJob 中使用 gerrit-trigger
- telegram - 无法将 Cloud Foundry 应用程序(红色节点)连接到 Watson Assistant
- c++ - 指针的动态数组,如何正确执行?
- sql - 在 SQL Server 中存储比分配列更多的字符
- python - 如何序列化 Wagtail 可订购模型?
- python - Bcbio-gff 文件创建问题
- c# - C# 单元测试无法识别其他类
- delphi - 如何使用尚未初始化的变量
- html - 多组件的routerLink
- javascript - 使用javascript在浏览器中捕获后退按钮的事件