Flutter 使用GestureDetector自定义卡片包装时,颤振列表视图不滚动
我有一个列表视图来显示卡片列表。当用户单击卡片时,将调用详细信息页面。为了识别点击手势,我用GestureDetector包装了CustomCard,但在此之后列表不再滚动Flutter 使用GestureDetector自定义卡片包装时,颤振列表视图不滚动,flutter,dart,flutter-listview,Flutter,Dart,Flutter Listview,我有一个列表视图来显示卡片列表。当用户单击卡片时,将调用详细信息页面。为了识别点击手势,我用GestureDetector包装了CustomCard,但在此之后列表不再滚动 class PageUI extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( body: SingleChildScrollView( child
class PageUI extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
SizedBox(height: 48),
Text(
'PageTitle',
style: Get.theme.textTheme.headline5,
),
SizedBox(height: 18),
ListView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: list.length,
itemBuilder: (context, index) => GestureDetector(
child: CustomCard(item: list[index]),
onTap: () {
// Navigate to DetailsPage
},
),
),
],
),
),
);
}
}
请试一试
ListView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: 10,
itemBuilder: (context, index) => GestureDetector(
child: CustomCard(item: list[index]),
onTap: () {
// Navigate to DetailsPage
},
),
),
工作真的很好。。。立刻解决了我的问题