Abhay V Ashokan
Abhay V Ashokan

Reputation: 402

Gesture detector detects only the children inside the container and not the blank space in the container

I have a container with a column as child and stack as immediate parent. onTap method only works when I press the Text widgets rendered inside the column widget and not the blank space of the container.

Upvotes: 3

Views: 196

Answers (1)

Martin Braun
Martin Braun

Reputation: 12629

The default behavior of the GestureDetector is to react only on rendered content and let the press bubble up instead, if it can't find a child rendered in that position. You can, however, change the behavior of the GestureDetector to always report a hit, no matter you press in a rendered child or not:

// On GestureDetector:
behavior: HitTestBehavior.translucent,

Upvotes: 0

Related Questions