body: (
SafeArea(
child: SingleChildScrollView(
child: Column(
children: [
ListView.builder(
itemBuilder: (context,index)
{
return(
Container(
height: 100,
width: 100,
color: Colors.red,
)
);
},
itemCount: 20,
),
],
)
),
)
),
我想让它成为可滚动的项目列表,基本上是试图复制 instagram 的用户界面
既然
ListView.builder
已经包括滚动你不需要使用SingleChildScrollView
,你有什么具体要求同时使用它们吗?如果是这样,您可以尝试将 ListView
包装成 SizedBox
并指定固定高度。
试试这个:
body: SafeArea(
child: ListView.builder(
physics: const AlwaysScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilder: (context, index) {
return Container(
padding: const EdgeInsets.only(bottom: 10),
height: 100,
width: 100,
color: Colors.red,
);
},
itemCount: 20,
),
),