Reputation: 83
I've got a problem with onTap event for GestureDedector. I tried in card too but not working. When I tap sizedbox nothing happens.
GestureDetector(
onTap: () => GoToPage(),
child: SizedBox(
child: Card(
child: Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: <Widget>[
Image.asset(
"assets/png/icon2.png",
width: 64.0,
),
...
Thank you.
Upvotes: 5
Views: 4030
Reputation: 167
By default a GestureDetector with an invisible child ignores touches, this behavior can be controlled with behavior. https://flutter.dev/docs/development/ui/advanced/gestures
Upvotes: 2
Reputation: 2089
you need to specify GestureDetector behaviour
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: (){},
),
Upvotes: 6
Reputation: 202
Try to add behavior property of GestureDetector
GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: (){},
),
Upvotes: 5