Handling multitouch in flutter

2020-04-19 08:14发布

问题:

In flutter, there is a standard GestureDetector that allows to interprets the commands "touch down", "touch move" and "touch up" by means of the corresponding handlers:

  • onPanStart: _handlePanStart,
  • onPanUpdate: _handlePanUpdate,
  • onPanEnd: _handlePanEnd,

However, we are talking about processing a single touch, but what if I want to handle several parallel touches and movements? I.e. really use multitouch? Is there any kind of built-in control in flutter (maybe multitouch gesture detector, I don't known) that allows to get a vector or a list of events of clicks, movements, ups with ids of touches and their current coordinates?

回答1:

Looks like you are looking for MultiDragGestureRecognizer. Look into this thread to know more.

Edit : There is no direct widget that you can use. You'll need to create a StatefulWidget that instantiates the MultiDragGestureRecognizer, then have your build function have a Listener that routes the onPointerDown event to the recognizer.



标签: dart flutter