flutter divider: How could i add divider between each line in my code?

前端 未结 7 1368
野趣味
野趣味 2020-12-02 12:00

How could i add divider to list? I use flatter for android. I want to add a divider between each line and I want to colorize the divider and add styles.

I tried to

7条回答
  •  情书的邮戳
    2020-12-02 13:01

    The most correct way is to use ListView.separated

    ListView.separated(
         itemCount: 25,
         separatorBuilder: (BuildContext context, int index) => Divider(height: 1),
         itemBuilder: (BuildContext context, int index) {
           return ListTile(
             title: Text('item $index'),
           );
         },
    );
    

提交回复
热议问题