My app has a similar widget tree to what’s below. onTap
is called when any of the containers are tapped.
How can I make it run only when the first container (the one with the red background) is tapped?
GestureDetector(
onTap: () => print('pressed'),
child: Container(
padding: const EdgeInsets.all(10),
color: Colors.red,
child: Container(
padding: const EdgeInsets.all(10),
color: Colors.green,
child: Container(
height: 50,
color: Colors.blue,
),
),
),
),
I tried IgnorePointer and AbsorbPointer but they only work on widgets that handle pointer events (buttons, scrollables, GestureDetector, …).
2
Answers
Not sure if this has any unwanted side effects, but it seems to work.
You can use
Stack
,