【发布时间】:2019-08-30 10:35:51
【问题描述】:
我找不到与此相关的任何内容,所以我想我做错了什么。我试图在BoxDecoration 中显示DecorationImage,但我的屏幕上根本没有显示任何内容。
我尝试使用Image.asset('assets\\test.png'); 显示相关资产,并且没有问题。我曾尝试将AssetImage 或FileImage 之类的内容放在DecorationImage 中,但似乎它们都不适合我。
我的代码基本如下:
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Container(
decoration: new BoxDecoration(
image: new DecorationImage(
image: new AssetImage('assets\\test.png'),
fit: BoxFit.cover,
),
),
),
],
),
)
);
我应该怎么做才能让我的test.png 显示?目前我只看到一个空屏幕。
【问题讨论】: