Flutter: How do you make a card clickable?
I think you can also use InkWell apart from GestureDetector just wrap the card inside InkWell()
Widget
InkWell(
onTap: (){ print("Card Clicked"); }
child: new Card(),
);
You can use Inkwell and insert splashColor which, at the click of the user, creates the rebound effect with the chosen color, on the card .. This is mainly used in material design.
return Card(
color: item.completed ? Colors.white70 : Colors.white,
elevation: 8,
child: InkWell(
splashColor: "Insert color when user tap on card",
onTap: () async {
},
),
);
Flutter provides the InkWell Widget. by registering a callback you can decide what happens when user clicks on the card (called tap in flutter). InkWell also implements Material Design ripple effect
Card(
child: new InkWell(
onTap: () {
print("tapped");
},
child: Container(
width: 100.0,
height: 100.0,
),
),
),
Flutter use composition over properties. Wrap the desired widget into a clickable one to achieve what you need.
Some clickable widgets : GestureDetector
, InkWell
, InkResponse
.
GestureDetector(
onTap: () => ......,
child: Card(...),
);