How to remove overscroll on ios?
I found this answer (https://stackoverflow.com/a/51119796/5869913) and just added information about deleting overscroll effect.
The overscroll effect comes from BouncingScrollPhysics
added by ScrollBehavior
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
.
The following ScrollBehavior will remove the overscroll effect entirely :
class MyBehavior extends ScrollBehavior {
@override
ScrollPhysics getScrollPhysics(BuildContext context) => ClampingScrollPhysics();
}
You can also remove glow effect with override of method buildViewportChrome like this:
@override
Widget buildViewportChrome(BuildContext context, Widget child, AxisDirection axisDirection) => child;
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(),
);
To remove it on a specific ListView, instead wrap only the desired ListView :
ScrollConfiguration(
behavior: MyBehavior(),
child: ListView(
...
),
)
or just set physics: ClampingScrollPhysics()
in the ListView
You don't need to do those fancy stuff if you only want to remove overscroll behavior on iOS. Simply, use:
ListView(
physics: ClampingScrollPhysics(),
)