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())
],
),
),
);
}
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: () { /* ... */ },
),
],
),
),
],
),
)
);
}
Help Me.
Solution: Use visualDensity property instead within the ListTile .
you are using expanded widget inside row so that both the widget try to get same width and also try to cover whole width possible. so that, if you want to remove space between row widget then remove expanded widget and play with MainAxisAlignment property of Row to arrange or manage the space.
ListView. separated creates a fixed-length, scrollable , linear array of list “items” separated by list item “separators”. The itemBuilder callback is called whenever there are indices ≥ 0 and< itemCount .
The spaces that you are getting between cards is from getRow() method.
Just update your
new Padding(padding: new EdgeInsets.all(10.0),
to
new Padding(padding: new EdgeInsets.all(1.0),
and see the change.
If you don't want any spaces in between, you can directly return Card();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With