首页 > 解决方案 > 以墨水飞溅的方式更改按钮的颜色

问题描述

我想在墨水飞溅后更改按钮的颜色。详细说明一下,我希望按钮的颜色改变它在墨水飞溅中的作用方式,墨水飞溅颜色的差异实际上会改变按钮的颜色。

在此处输入图像描述

就像上面的 gif 一样,当用户按下按钮时,由于墨水飞溅,按钮的颜色会发生变化,但是当用户停止按下按钮时,它会恢复到正常颜色。我知道我可以在onPressed方法中更改实际按钮的颜色,但这并没有给我想要的飞溅效果。一个例子可能是:

在此处输入图像描述

对我来说有点难以解释,因为我无法真正表达我的意思。随时发表评论以获得进一步的解释。

标签: flutterflutter-layout

解决方案


我通常使用平面按钮来实现这种高亮颜色效果:

FlatButton(
  onPressed: onPressed,
  highlightColor: Colors.blue.shade300, // your highlight color here
  color: Colors.blue, // normal button color here
  shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
  padding: const EdgeInsets.symmetric(vertical: 15),
  child: child
),

推荐阅读