如何在iOS上消除过度滚动? [英] How to remove overscroll on ios?
问题描述
默认情况下,在iOS上的 ListView / GridView /...
上,颤振默认添加过度滚动
效果
By default, flutter adds a overscroll
effect on ListView/GridView/...
on ios
我想完全删除此效果或在一个特定的滚动条上删除。
I would like to remove this effect entirely or on one specific scrollable.
我该怎么办?
推荐答案
我找到了这个答案( https:// stackoverflow.com/a/51119796/5869913 ),只是添加了有关删除过度滚动效果的信息。
I found this answer (https://stackoverflow.com/a/51119796/5869913) and just added information about deleting overscroll effect.
过度滚动效果来自 BouncingScrollPhysics
由 ScrollBehavior
要删除此效果,您需要指定一个自定义 ScrollBehavior
并覆盖 getScrollPhysics
方法。为此,只需将应用程序的任何给定部分包装到具有所需的 ScrollBehavior
的 ScrollConfiguration
中。
To remove this effect, you need to specify a custom ScrollBehavior
and override getScrollPhysics
method. For that, simply wrap any given part of your application into a ScrollConfiguration
with the desired ScrollBehavior
.
以下ScrollBehavior将完全消除过度滚动效果:
The following ScrollBehavior will remove the overscroll effect entirely :
class MyBehavior extends ScrollBehavior {
@override
ScrollPhysics getScrollPhysics(BuildContext context) => ClampingScrollPhysics();
}
您还可以使用方法buildViewportChrome覆盖辉光效果,如下所示:
You can also remove glow effect with override of method buildViewportChrome like this:
@override
Widget buildViewportChrome(BuildContext context, Widget child, AxisDirection axisDirection) => child;
要删除整个应用程序的过度滚动,可以将其添加到MaterialApp下:
To remove the overscroll on the whole application, you can add it right under MaterialApp :
MaterialApp(
builder: (context, child) {
return ScrollConfiguration(
behavior: MyBehavior(),
child: child,
);
},
home: MyHomePage(),
);
要在特定的ListView上将其删除,请仅包装所需的ListView:
To remove it on a specific ListView, instead wrap only the desired ListView :
ScrollConfiguration(
behavior: MyBehavior(),
child: ListView(
...
),
)
或仅设置物理: ClampingScrollPhysics()
在ListView中
or just set physics: ClampingScrollPhysics()
in the ListView
这篇关于如何在iOS上消除过度滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!