Search code examples
flutterlistview

How to set the default Scroll Physics of an android flutter app


I am developing a flutter app, and simply want to change the default scrolling physics to BouncingScrollPhysics so my listviews are more modified.

I know that there is already an answered question but it doesn't work on the latest version of flutter.

I wouldn't want to go around my app changing ListView properties an doing bad practices, any help would be appreciated <3


Solution

  • Similar to this solution: Default ScrollPhysics

    class MyScrollBehavior extends ScrollBehavior {
      const MyScrollBehavior();
      @override
      ScrollPhysics getScrollPhysics(BuildContext context) => const BouncingScrollPhysics();
    }
    
    MaterialApp(
      scrollBehavior: MyScrollBehavior(),
      // ...
    );