flutterflutter-layoutflutter-testflutter-widgetflutter-card

GestureDedector's onTap event not working for Sizedbox


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: (){},
    ),