【问题标题】:How to differentiate between finger touch gestures and mouse pointer gestures in flutter web?flutter web中如何区分手指触摸手势和鼠标指针手势?
【发布时间】:2021-05-06 08:34:31
【问题描述】:

我正在研究颤振网络。 我需要实现手指触摸特定代码和鼠标特定代码。 我使用了 Listener 小部件。但它可以识别屏幕上的鼠标平移和手指平移。 但我只需要鼠标平移。 请告诉我区分手指触摸手势和鼠标指针手势的代码。 监听代码:

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

【问题讨论】:

    标签: flutter dart web flutter-web


    【解决方案1】:

    您可以从 TapDownDetails 获取 PointerDeviceKind。请参考以下代码。

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

    在监听器中

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-28
      • 1970-01-01
      • 2023-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多