flutterdialoggesturedetector

show dialog when long pressed and pop it when finger up


I want to show a dialog when user long pressed on an item and pop it when finger up but it can't detect tap up.

I put dialog on another GestureDetector and use onTapUp property of it to pop dialog.

GestureDetector(
 child: studentIcon(index, context),
 onLongPress: () {
   showDialog(
       context: context,
       builder: (context) {
         return GestureDetector(
           onTapUp: (detail) {
             Navigator.pop(context);
           },
           child: DialogDetail(
             index: index,
           ),
         );
       });
 },

I expect to pop dialog after finger up after long pressed.


Solution

  • You can't do that as there is an context problem in GestureDetector. Please follow this answer to implement this thing.