GestureDetector not working?

1,295 views
Skip to first unread message

徐竞欧

unread,
Sep 18, 2018, 5:59:46 PM9/18/18
to flutt...@googlegroups.com
Hi awesome Flutter team,
Yesterday I encountered one strange problem, and I'm wondering if you can shed any light. Basically I have a GestureDetector, and I can see the widget rendered on the screen through Flutter Inspector. However its onTap() is never triggered when I tap the screen. I did see the ACTION_DOWN and ACTION_UP was logged to console when I tap the screen, which means the hardware is working correctly.

For more context, I was following a tutorial online(https://www.youtube.com/watch?v=GFRfSM4yA9U) and trying to do some enhancement on top of it. Specifically I'm trying to wrap this Row (https://github.com/…/recordi…/lib/forecast/radial_list.dart…) with a GestureDetector, so that it can react to my taps. You can see this Row is embedded layers inside an AnimatedBuilder. I'm not sure if that will impact the gesture detection? Any help and suggestion is appreciated. 

Thank you very much!
Jingou

徐竞欧

unread,
Sep 19, 2018, 1:57:02 AM9/19/18
to Flutter Dev
Just want to update how I did it with a workaround.
I created several GestureDetectors at the those positions where there are the icon widgets that I'd like them to react to my tapping. Basically these GestureDetectors cover those widgets. But this is not enough, I have to wrap those icon widgets with a Stack and put a dummy GestureDetector which doesn't register any callbacks to any gestures in the Stack. Only in this way can  those covering GestureDetectos trigger onTap. If I remove the dummy GestureDetector in the Stack in which the icon widgets reside, the covering GestureDetectors won't work. I don't know why this works, but it does work. 
Reply all
Reply to author
Forward
0 new messages