In flutter 2.2, you could use mouse to swipe up and down on a ListView
. It would act like swiping by finger on touch screens. However in version 2.5 this seems to have been removed and now clicking won't do what touch does, for example over-scrolling a BouncingScrollPhysics
(something I'm relying on in my app).
Is there any way to re-enable the simulation functionality?
In newer versions the mouse drag ability has been removed on scrollable widgets however you can enable it in two ways.
First you need to create this class:
class MyCustomScrollBehavior extends MaterialScrollBehavior {
@override
Set<PointerDeviceKind> get dragDevices => {
PointerDeviceKind.touch,
PointerDeviceKind.mouse,
};
}
Then enable it in your app like this:
Wrap your scrollable inside a ScrollConfiguration
and set the behavior
:
ScrollConfiguration(
behavior: MyCustomScrollBehavior(),
child: ListView(
...
)
)
In your MaterialApp
set the scrollBehavior
:
MaterialApp(
scrollBehavior: MyCustomScrollBehavior(),
...
)
TIP: If you have multiple nested MaterialApp
s, you have to set scrollBehavior
on all of them.