19

I'm trying to make a list on my flutter app. But, Every time I scroll all the way to the top there is this animation showing up like this:

https://i.stack.imgur.com/Z7mHh.jpg, https://i.stack.imgur.com/EAIyj.jpg

Is there a way to hide this animation?

Young
  • 1,061
  • 3
  • 12
  • 28

6 Answers6

34
NotificationListener<OverscrollIndicatorNotification>(
    onNotification: (OverscrollIndicatorNotification overscroll) {
      overscroll.disallowGlow();
    },
    child: ListView.builder(...));

As official docs say

GlowingOverscrollIndicator generates OverscrollIndicatorNotification before showing an overscroll indication. To prevent the indicator from showing the indication, call OverscrollIndicatorNotification.disallowGlow on the notification.

Andrii Turkovskyi
  • 27,554
  • 16
  • 95
  • 105
27

This will help you just add this in your Listview.builder

physics: ClampingScrollPhysics(),
15

You can solve this problem using two methods.

  1. if you can afford bounce back effect then simply use ListView.builder's property physics and set value BouncingScrollPhysics() like this:

    physics: BouncingScrollPhysics()
    
  2. you can also solve it using ScrollConfiguration and custom ScrollBehavior.

See for this post for details.

romellem
  • 5,792
  • 1
  • 32
  • 64
Viren V Varasadiya
  • 25,492
  • 9
  • 45
  • 61
  • 1
    `physics: BouncingScrollPhysics()` solution does not work with `ScrollablePositionedList.builder`. Any solution. Thanks. – Kamlesh Jun 23 '21 at 13:33
3

MD Khali , Here is the code using SingleChildScrollView

@override
Widget build(BuildContext context) {
return Scaffold(
  body: Center(
    child: NotificationListener<OverscrollIndicatorNotification>(
      onNotification: (OverscrollIndicatorNotification overScroll) {
        overScroll.disallowGlow();
        return false;
      },
      child: SingleChildScrollView( ..... )
    )
  )
 )
0

You should try this, it helped me

const BouncingScrollPhysics(parent: AlwaysScrollableScrollPhysics())

https://api.flutter.dev/flutter/widgets/BouncingScrollPhysics-class.html

0

to disable glow effect of ClampingScrollPhysics which is the default behavior for Android you can use scrollBehavior property of MaterialApp

    return MaterialApp.router(
      scrollBehavior: _ScrollBehaviourWithoutGlowEffect(),
...............



class _ScrollBehaviourWithoutGlowEffect extends MaterialScrollBehavior {
  @override
  Widget buildOverscrollIndicator(BuildContext context, Widget child, ScrollableDetails details) {
    return child;
  }
}
Fuad All
  • 871
  • 11
  • 13