我有一个充满图片的列表视图。图像被一个接一个地放置。它们之间没有空隙,但我需要一些空间。有什么东西像
在HTML里?当我将填充添加到ListView中时,图像上的任何内容都不会改变。我必须在每一张图片上加上填充吗?
我尝试添加填充:新的EdgeInsets.only(底部: 5.0,),扩展和ListView。我在image.assets上也尝试过同样的方法。对我没什么用。
child: new ListView(
children: [
Image.asset('images/offers/Beardshave.jpg',
height: 240.0,
fit: BoxFit.fill,),
Image.asset('images/offers/GelNails.jpg',
height: 240.0,
fit: BoxFit.fill,),
Image.asset('images/offers/Getintouch.jpg',
height: 240.0,
fit: BoxFit.fill,),
Image.asset('images/offers/HotStone.jpg',
height: 240.0,
fit: BoxFit.fill,),
Image.asset('images/offers/Lavendel-oil.jpg',
height: 240.0,
fit: BoxFit.fill,),
Image.asset('images/offers/Paarmassage.jpg',
height: 240.0,
fit: BoxFit.fill,)
],
),
),发布于 2019-09-02 16:59:56
是的,您必须通过用填充小部件包装图像来向每个图像添加填充。另一种解决方案是在图像与Widget之间添加空间,如下所示:
[
Image.asset('images/offers/Beardshave.jpg',
height: 240.0,
fit: BoxFit.fill,),
SizedBox(height: 10,),
Image.asset('images/offers/GelNails.jpg',
]发布于 2019-09-02 16:26:47
您可以创建一个像ImageWithPadding这样的组件,并返回一个填充小部件,其中包含image.asset。
就像这样:
ImageWithPadding() {
return Padding(
padding: EdgeInsets.all(8.0),
child: Image.asset('images/offers/Paarmassage.jpg',
height: 240.0,
fit: BoxFit.fill,)
)https://stackoverflow.com/questions/57758458
复制相似问题