Reputation: 11640
I'd love to have a ListView
where there are 4 ListTile
s and a divider right before its last ListTile
, but I don't want the horizontal line with the Divider
, only a blank space with customizable height.
So far I haven't found a straightforward way other than inserting an empty container before the last two tiles.
The thing is: I have a model List
behind the ListView
. I'd love to match the selected items in the list to the ListView. So there had better be a 1-to-1 mapping between data and view. This makes it convenient to configure the looks for selecting the ListTiles. Having a non-data divider in the view skews the mapping, i.e., now I'd have 4 data items, but 5 items in the view. So I couldn't just use
child: ListTile(
selected: model[i].isSelected,
)
Am I asking for too much from the ListView
or is there a straightforward way to achieve what I want?
Upvotes: 2
Views: 732
Reputation: 1333
you can use ListView.separated
ListView.separated(
itemCount: 25,
separatorBuilder: (BuildContext context, int index) => SizedBox ( height : <height>),
itemBuilder: (BuildContext context, int index) {
return ListTile(
title: Text('item $index'),
);
},
)
Upvotes: 3