Aeg*_*tes 7 assets image dart flutter
我找不到与此相关的任何内容,所以我想我做错了什么。我试图显示一个DecorationImage
inside BoxDecoration
,但我的屏幕上根本没有显示任何内容。
我尝试显示相关资产,Image.asset('assets\\test.png');
并且没有问题。我曾尝试将诸如AssetImage
或FileImage
inside 之类的东西放入其中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,
),
),
),
],
),
)
);
Run Code Online (Sandbox Code Playgroud)
我应该怎么做test.png
才能展示我的作品?目前我只看到一个空屏幕。
Cop*_*oad 21
你需要像这样给予width
和height
给你的Container
new Container(
height: 100,
width: 100,
decoration: new BoxDecoration(
image: new DecorationImage(
image: new AssetImage('assets\\test.png'),
fit: BoxFit.cover,
),
),
),
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
11625 次 |
最近记录: |