使用ListView.separated,就很简单了
ListView.separated(
scrollDirection: direction,
itemBuilder: (context, index) {
final Axis slidableDirection =
direction == Axis.horizontal ? Axis.vertical : Axis.horizontal;
return _getSlidableWithLists(context, index, slidableDirection);
},
itemCount: list.length,
separatorBuilder: (BuildContext context, int index) =>
Divider(height: 1.0, color: AppColors.separator),
);
如果使用ListView.builder,没有这个属性,需要自己在itemBuilder中增加下划线
ListView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (BuildContext context, int index) =>
GroupContactItem(_headData[index], groupModel),
itemCount: _headData.length)
],
效果如下:
喜欢可以加Q群号:913934649,点赞,评论;
简书: https://www.jianshu.com/u/88db5f15770d