0

I am new at flutter how can i get onTap command in gridview.count

I tried to make the images clickable but i can't get the command onTap in gridview.count

 Widget buildBody() {
    return SafeArea(
        child: Container(
      padding: EdgeInsets.all(20.0),
      child: Column(
        children: <Widget>[
          Expanded(
              child: GridView.count(
            crossAxisCount: 2,
            padding: EdgeInsets.all(20),
            crossAxisSpacing: 20,
            mainAxisSpacing: 20,
            children: _products
                .map(((item) => Card(
                      child: Container(
                        decoration: BoxDecoration(
                            image: DecorationImage(
                                image: Image.asset(item.imageUrl),
                                fit: BoxFit.fill)),
                      ),
                    )))
                .toList(),
          )),
        ],
      ),
    ));
  }

And this is the list that i get to images

List<Product> _products = <Product>[
  Product("Özel Kesim Magnet", "Özel Kesim Magnet", "assets/icons/ökm.png"),
  Product("Kuşe Etiketler", "kş", "assets/icons/ke.png"),
  Product("Opak Etiketler", "oe", "assets/icons/oe.png"),
  Product("Şeffaf Etiketler", "şe", "assets/icons/şe.png"),
  Product("Kutu Kesim", "ks", "assets/icons/kk.png"),
  Product("Tam Kesim", "tk", "assets/icons/tk.png"),
  Product("Özel Kesim", "ÖK", "assets/icons/ök.png"),
  Product("Folyo Kesim", "fk", "assets/icons/fk.png")
];
  • 2
    Does it solve your problem? --> https://stackoverflow.com/questions/49959617/flutter-how-do-you-make-a-card-clickable – Rob Aug 01 '21 at 19:12

1 Answers1

1

Wrap your card with GestureDetector or InkWell.

GestureDetector(
  onTap: () {},
  child: Card(...),
);
Zohaib Tariq
  • 548
  • 8
  • 15