Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

onTapUp isn't called after onLongPress

I'm trying to create a context menu that is displayed after a long press whilst keeping your finger held on the object, afterwards you would select an option (by dragging your finger) and lift it to initiate the action.

I noticed something that to me is a little strange. So first, the code:

    import 'package:flutter/material.dart';
    
    void main() {
      runApp(MaterialApp(
        home: Scaffold(
          body: GestureDetector(
            onLongPress: () {
              print("onLongPress");
            },
            onTapUp: (TapUpDetails details) {
              print("onTapUp");
            },
            child: Center(
              child: FlutterLogo(),
            ),
          ),
        ),
      ));
    }

So if I run this, after long pressing the icon, then the handler for onLongPress is called but after lifting your finger onTapUp isn't called. If I comment out the handler for onLongPress (all 3 lines) then after a long press onTapUp is called. I would like to handle both onTapUp and onLongPress.

Any ideas why this is happening?

like image 966
NotAVampire Avatar asked May 19 '18 15:05

NotAVampire


Video Answer


1 Answers

You can wrap in another gesture detector that will handle tap up.

I am not sure if current behavior is a bug, so you might want to submit it to issue tracker.

like image 159
Tree Avatar answered Oct 21 '22 13:10

Tree