少廢話 直接上代碼
在Flutter中,ListView組件默認會有水波紋效果,這是因為ListView在Android上使用了ScrollConfiguration來實現(xiàn)滑動。如果你想去除這個水波紋效果,可以使用NotificationListener來攔截滾動通知,并通過OverscrollIndicatorNotification來控制水波紋的顯示。
以下是去除ListView滑動水波紋的示例代碼:
Expanded(
child: NotificationListener<OverscrollIndicatorNotification>(
onNotification: (OverscrollIndicatorNotification overscroll) {
overscroll.disallowIndicator();
return true;
},
child: ListView.builder(
itemCount: 100,
itemBuilder: (BuildContext context, int index) {
return ListTile(title: Text('Item $index'));
},
),
),
),
試過定義一個ScrollBehavior 將 ScrollBehavior 配置到 ScrollConfiguration 中 , 上下滑動水波紋依然存在. 所以就試了試上述方法.