Posted By

markt22 on 07/17/18


Tagged

flutter dart


Versions (?)

Flutter: ListView With Custom Dividers


 / Published in: JavaScript
 

A flutter ListView with a divider between each item. Unlike ListTile.divideTiles(), which only adds a 1 pixel divider, this code can add a divider with a custom height.

  1. body: ListView.builder(
  2. itemBuilder: (BuildContext context, int index) {
  3. if (index % 2 == 0) {
  4. return listItemWidgets[index ~/ 2];
  5. } else {
  6. return Divider(height: 10.0);
  7. }
  8. },
  9. itemCount: listItemWidgets.length * 2 - 1
  10. )

Report this snippet  

You need to login to post a comment.