LIstView构建器,用Padding包裹,没有裁剪

问题描述 投票:0回答:1

我想在ListViewBuilder的左侧实现填充,但是每当我添加填充并且用户滚动列表(水平轴)时,您都可以清楚地看到填充:

代码:

Widget build(BuildContext context) {
    return Padding(
              padding: const EdgeInsets.all(2.0),
              child: ListView.separated(
                     separatorBuilder: (context, index) => const SizedBox(width: 10,),
                     itemCount: 4,
                     scrollDirection: Axis.horizontal,
                     itemBuilder: (context, index) {
                        return Container(
                           height: 100,
                           width: 100,
                           color: Colors.grey,
                        );
                     },
              )
    );
}

enter image description here

flutter flutter-layout
1个回答
0
投票

ListView.seperator()上有padding属性

  child: ListView.separated(
    padding: const EdgeInsets.only(left: 2),
© www.soinside.com 2019 - 2024. All rights reserved.