Flutter: How do you make a card clickable?

后端 未结 6 1352
迷失自我
迷失自我 2020-12-15 02:40

I just have a simple Card like new Card(child: new Text(\'My cool card\')) and I want to be able to click anywhere on it to run some function, except there\'s n

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-15 03:08

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

提交回复
热议问题