I have a SizedBox
widget that occupies the whole width of the screen, and it has a child widget that has around 400px of width. When the SizedBox
is clicked, I’m calling the Navigator.pop
to go back to previous page. but I don’t want that to be called when the child widget is clicked. Currently, when I click the child widget, it also calls the onTap
function of the parent widget. How can I prevent that?
GestureDetector(
onTap: () {
print("GestureDetector Outer");
final isDismissible = ModalRoute.of(context)?.barrierDismissible;
if (isDismissible == true) {
Navigator.pop(context);
}
},
child: SizedBox(
width: double.maxFinite,
child: Row(
children: [
SizedBox(
width: 400,
child: _content(),
),
],
),
),
)
2
Answers
Try with wrapping your child widget in to
IgnorePointer
widget.Try this!
You need to wrap your child widget with gesturedetector. also you can use IgnorePointer widget.