Refactor scroll behavior to improve accessibility and support for various input devices

This commit is contained in:
Moustapha Kodjo Amadou 2025-06-20 16:51:14 +01:00
parent ef47210af8
commit 2b8625bf0e

View file

@ -118,7 +118,7 @@ class _MyAppState extends ConsumerState<MyApp> {
routerDelegate: router.routerDelegate,
routeInformationProvider: router.routeInformationProvider,
title: 'MangaYomi',
scrollBehavior: AllowDesktopScrollBehavior(),
scrollBehavior: AllowScrollBehavior(),
);
}
@ -233,10 +233,21 @@ class _MyAppState extends ConsumerState<MyApp> {
}
}
class AllowDesktopScrollBehavior extends MaterialScrollBehavior {
class AllowScrollBehavior extends MaterialScrollBehavior {
// This allows the scrollable widgets to be scrolled with touch, mouse, stylus,
// inverted stylus, trackpad, and unknown pointer devices.
// This is useful for accessibility purposes, such as when using VoiceAccess,
// which sends pointer events with unknown type when scrolling scrollables.
// This is also useful for desktop platforms, where touch, stylus, and trackpad
// interactions are common, and we want to ensure a consistent scrolling experience
// across all devices.
@override
Set<PointerDeviceKind> get dragDevices => {
PointerDeviceKind.touch,
PointerDeviceKind.mouse,
PointerDeviceKind.stylus,
PointerDeviceKind.invertedStylus,
PointerDeviceKind.trackpad,
PointerDeviceKind.unknown,
};
}