Is it possible to take stylus input in Flutter?
Asked Answered
M

1

9

I want to make a drawing app using Flutter. There is this widget called CustomPaint that allows you to easily have a Canvas and draw on it with you fingers.

Let's say that I want to use a tablet with a dedicated stylus will CustomPaint take into account the pressure sensitivity automatically.

If not, what should I do for my app to support the stylus.

I've been looking around for example apps and the only ones I found don't even mention the possibility of pressure sensitivity or even just plain usage with stylus.

Example apps

https://github.com/vemarav/signature

https://github.com/psuzn/draw-it

Marishamariska answered 13/8, 2019 at 7:31 Comment(1)
It seems like it, though I haven't looked to deeply into it. api.flutter.dev/flutter/dart-ui/PointerData-class.html However, it's possible that it's not yet supported on Windows and Linus (Issues #65248 and #63209 under the Flutter repository)Whereof
E
2

For basic input handling you would use the GestureDetector widget.

For low level input detection you can use the Listener widget that has onPointerDown, onPointerMove, onPointerHover and onPointerUp event listeners (and much more), which you can use to get the information of your stylus.

The information you can get from the listeners can be found under the according PointerEvent given by each event listener. One of the information you can get from PointerEvent is the pressure.

You can find a basic introduction to input detection under Taps, drags, and other gestures.

Edveh answered 9/7, 2021 at 14:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.