本文介绍了Flutter:如何在Listview中删除行之间的空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是在做一些抖动的演示,我喜欢这样做,在列表视图中,我找不到如何删除行之间的空间
I am just doing some demos of flutter, I love to do it, In listview, I cant find out that how to remove space between rows
我的代码非常简单,这是一个小部件,我返回到自己的布局
my code is pretty simple, This one is Widget which I return to my layout
Widget _getWidget(BuildContext context) {
return new Material(
child: new Container(
padding: EdgeInsets.only(top: 20.0),
color: Colors.blueGrey[500],
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
_getHeader(context),
new Expanded(child: getListView())
],
),
),
);
}
这是Listview
This one is Listview
ListView getListView() =>
new ListView.builder(
itemCount: widgets.length,
itemBuilder: (BuildContext context, int position) {
return getRow(position);
});
这是我使用卡片视图的行
This one is row which i use card view
Widget getRow(int i) {
return new Padding(padding: new EdgeInsets.all(10.0),
child: new Card(
child: new Column(
children: <Widget>[
new ListTile(
title: new Text(
"Name : ${widgets[i].username}"
),
subtitle: new Text(
"Decription : You may go now!!"
),
),
new ButtonTheme.bar(
child: new ButtonBar(
children: <Widget>[
new FlatButton(
child: const Text('Accept'),
onPressed: () { /* ... */ },
),
new FlatButton(
child: const Text('Reject'),
onPressed: () { /* ... */ },
),
],
),
),
],
),
)
);
}
救救我.
推荐答案
在卡片之间获得的空格来自 getRow()方法.
The spaces that you are getting between cards is from getRow() method.
只需更新
new Padding(padding: new EdgeInsets.all(10.0),
到
new Padding(padding: new EdgeInsets.all(1.0),
并查看更改.
如果您不想在它们之间留任何空格,可以直接返回Card();
If you don't want any spaces in between, you can directly return Card();
这篇关于Flutter:如何在Listview中删除行之间的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!