I am trying to build a ListView with dividers between each ListTile. I saw that there is a static method to do that called divideTiles() but i did not understand how to use that.. How/where is this function used?
My code is a simple ListView with ListTiles as children.
If you have a list of widgets, you may need to add a separator between the widgets. In Flutter, there are two widgets suitable for that purpose: Divider and VerticalDivider . Divider is used to create a horizontal line divider, while VerticalDivider is used to create a vertical line divider.
To add ListTile bottom or top border, you can wrap the ListTile widget inside the Container and add the decoration. Inside the decoration parameter, add the Boxdecoration widget with border parameter and assign it to either Border(bottom: new BorderSide()) or Border(bottom: new BorderSide()).
separated. In Flutter, you can use ListView. separated to easily create a list view whose items are separated by separators (or dividers). A separator only appears between two list items and never stands before the first or sits after the last item.
ListView(
children: ListTile.divideTiles(
context: context,
tiles: [
// your widgets here
]
).toList(),
)
Alternatively you can go with ListView.separated
:
ListView.separated(
itemCount: 42,
itemBuilder: (context, index) {
// your widget here
},
separatorBuilder: (context, index) {
return Divider();
},
);
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