当你在 ListView.builder 中一直滚动到顶部时,如何禁用动画
How can I disable the animation when you scroll all the way to the top in ListView.builder
我正在尝试在我的 flutter 应用程序中列出一个列表。但是,每次我一直滚动到顶部时,都会出现这样的动画:
https://i.stack.imgur.com/Z7mHh.jpg,
https://i.stack.imgur.com/EAIyj.jpg
有没有办法隐藏这个动画?
您可以使用两种方法解决此问题。
如果你能负担得起反弹效果,那么只需使用 ListView.builder
的 属性 physics
并像这样设置值 BouncingScrollPhysics()
:
physics: BouncingScrollPhysics()
你也可以使用ScrollConfiguration
和自定义ScrollBehavior
来解决它。
.
NotificationListener<OverscrollIndicatorNotification>(
onNotification: (OverscrollIndicatorNotification overscroll) {
overscroll.disallowGlow();
},
child: ListView.builder(...));
GlowingOverscrollIndicator generates OverscrollIndicatorNotification before showing an overscroll indication. To prevent the indicator from showing the indication, call OverscrollIndicatorNotification.disallowGlow on the notification.
这将帮助您将其添加到 Listview.builder
physics: ClampingScrollPhysics(),
MD Khali,这里是使用 SingleChildScrollView 的代码
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: NotificationListener<OverscrollIndicatorNotification>(
onNotification: (OverscrollIndicatorNotification overScroll) {
overScroll.disallowGlow();
return false;
},
child: SingleChildScrollView( ..... )
)
)
)
我正在尝试在我的 flutter 应用程序中列出一个列表。但是,每次我一直滚动到顶部时,都会出现这样的动画:
https://i.stack.imgur.com/Z7mHh.jpg, https://i.stack.imgur.com/EAIyj.jpg
有没有办法隐藏这个动画?
您可以使用两种方法解决此问题。
如果你能负担得起反弹效果,那么只需使用
ListView.builder
的 属性physics
并像这样设置值BouncingScrollPhysics()
:physics: BouncingScrollPhysics()
你也可以使用
ScrollConfiguration
和自定义ScrollBehavior
来解决它。
NotificationListener<OverscrollIndicatorNotification>(
onNotification: (OverscrollIndicatorNotification overscroll) {
overscroll.disallowGlow();
},
child: ListView.builder(...));
GlowingOverscrollIndicator generates OverscrollIndicatorNotification before showing an overscroll indication. To prevent the indicator from showing the indication, call OverscrollIndicatorNotification.disallowGlow on the notification.
这将帮助您将其添加到 Listview.builder
physics: ClampingScrollPhysics(),
MD Khali,这里是使用 SingleChildScrollView 的代码
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: NotificationListener<OverscrollIndicatorNotification>(
onNotification: (OverscrollIndicatorNotification overScroll) {
overScroll.disallowGlow();
return false;
},
child: SingleChildScrollView( ..... )
)
)
)