How to use divideTiles() in Flutter?

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(); 
  },
);

Here is a supplemental answer that shows what the divider looks like:

enter image description here

ListView(
  children: ListTile.divideTiles(
      context: context,
      tiles: [
        ListTile(
          title: Text('Horse'),
        ),
        ListTile(
          title: Text('Cow'),
        ),
        ListTile(
          title: Text('Camel'),
        ),
        ListTile(
          title: Text('Sheep'),
        ),
        ListTile(
          title: Text('Goat'),
        ),
      ]
  ).toList(),
)

From here


If you are using listview you can go with this alternate

ListView.builder(itemBuilder: (context, index){
    return ListTile(title: new Column(children: <Widget>[
      new Text('Hello how are you?'),
      new Divider(height: 20.0,)// add value for height or leave it blank for default
    ],) );
  })

Tags:

Flutter