flutter: listview blank divider
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'),
);
},
)

kakyo
Updated on December 22, 2022Comments
-
kakyo 2 minutes
Goal
I'd love to have a
ListView
where there are 4ListTile
s and a divider right before its lastListTile
, but I don't want the horizontal line with theDivider
, only a blank space with customizable height.Problem
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 theListView
. 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 usechild: ListTile( selected: model[i].isSelected, )
Question
Am I asking for too much from the
ListView
or is there a straightforward way to achieve what I want?-
Shubham Gupta over 2 yearsDid you check
ListView.separated
?
-