📜  扑动 IconButton 改变颜色 onPressed - 任何代码示例

📅  最后修改于: 2022-03-11 14:58:45.127000             🧑  作者: Mango

代码示例1
class SomeState extends State {
  Color _iconColor = Colors.white;

  @override
  Widget build(BuildContext) {
    return ListTile(
      leading: new IconButton(
        icon: Icon(Icons.star, color: _iconColor),
        onPressed: () {
          setState(() {
          _iconColor = Colors.yellow;
        });
      },
    );
  }
}