GestureDedector's onTap event not working for Sizedbox

Issue

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.

Solution

Try to add behavior property of GestureDetector

GestureDetector(
  behavior: HitTestBehavior.translucent,
  onTap: (){},
),

Answered By – Chelsi Prajapati

Answer Checked By – Willingham (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *