Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support PointerDeviceKind other than touch #274

Closed
dickermoshe opened this issue Oct 28, 2024 · 5 comments
Closed

Support PointerDeviceKind other than touch #274

dickermoshe opened this issue Oct 28, 2024 · 5 comments
Assignees
Labels
feature request New feature or request P2

Comments

@dickermoshe
Copy link

dickermoshe commented Oct 28, 2024

Love this package, thanks so much for it!

I develop mobile app using Device Preview. It's much easier that dealing with android/ios emulators.
image

However, scroll on these devices uses the scroll wheel, not touch, so I use a ScrollConfiguration widget to add touch support

const MaterialScrollBehavior().copyWith(
  dragDevices: {
    PointerDeviceKind.touch,
    PointerDeviceKind.mouse
})

However SheetDraggable still wasn't working! But then I found this

Widget build(BuildContext context) {
return RawGestureDetector(
gestures: {
VerticalDragGestureRecognizer:
GestureRecognizerFactoryWithHandlers<VerticalDragGestureRecognizer>(
() => VerticalDragGestureRecognizer(
debugOwner: kDebugMode ? runtimeType : null,
supportedDevices: const {PointerDeviceKind.touch},
),
(instance) => instance
..onStart = _handleDragStart
..onUpdate = _handleDragUpdate
..onEnd = _handleDragEnd
..onCancel = _handleDragCancel,
),

@fujidaiti Why is this hardcoded to touch devices only?

@fujidaiti
Copy link
Owner

Hi @dickermoshe,

Why is this hardcoded to touch devices only?

To be honest, I hadn’t given much thought to the desktop platforms as the package was originally intended for mobile.
But it seems like it would be a good idea to reconsider.

@fujidaiti fujidaiti added the feature request New feature or request label Oct 30, 2024
@fujidaiti fujidaiti changed the title Hardcoded Touch on SheetDraggable Support PointerDeviceKind other than touch Oct 30, 2024
@fujidaiti fujidaiti self-assigned this Oct 30, 2024
@fujidaiti fujidaiti added the P2 label Oct 30, 2024
@dickermoshe
Copy link
Author

Is there a reason we couldn't just replace that with?

VerticalDragGestureRecognizer(
  debugOwner: kDebugMode ? runtimeType : null,
  supportedDevices: ScrollConfiguration.of(context).dragDevices,
)

@dickermoshe
Copy link
Author

To support mouse wheels your gonna need to use a Listener
The code int SingleChildScrollView should help you

@fujidaiti
Copy link
Owner

fujidaiti commented Nov 1, 2024

To support mouse wheels your gonna need to use a Listener
The code int SingleChildScrollView should help you

It is difficult to support mouse wheels as it is incompatible with the momentum scrolling and the snapping effects of sheets. See this comment for more details.

Flutter treats mouse wheel scrolling as a series of tiny scrolls (onPointerDown → onPointerMove → onPointerUp → onPointerDown → onPointerMove → ...), which prevents momentum scrolling from working properly. This is particularly incompatible with the snapping effects.

@dickermoshe
Copy link
Author

dickermoshe commented Nov 1, 2024

Hmmm, that's disappointing.
Thanks Again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request P2
Projects
None yet
Development

No branches or pull requests

2 participants