How to differentiate between finger touch gestures and mouse pointer gestures in flutter web?

Issue

Im working on flutter web.
I need to implement finger touch specific code and mouse specific codes.
I have used Listener widget.but it recognizes both mouse panning and finger panning on screen.
But I need only mouse panning.
Kindly tell me the code which differentiate between finger touch gestures and mouse pointer gestures.
Listener code:

          Listener(
              onPointerMove: (details) {
                print('moved');
              },
              child: Container(height:500,width:300));

Solution

From the TapDownDetails you can get the PointerDeviceKind. Please refer the below code.

GestureDetector(
  onTapDown: (TapDownDetails details){
    PointerDeviceKind pointerType = details.kind;
  }
);

In Listener

Listener(
   onPointerMove: (details) {
     print('moved');
   },
   onPointerDown: (details){
     PointerDeviceKind pointerType =  details.kind
   },
  child: Container(height:500,width:300));

PonterType

Answered By – Balasubramani Sundaram

Answer Checked By – David Marino (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.