flutter - 以墨水飞溅的方式更改按钮的颜色
问题描述
我想在墨水飞溅后更改按钮的颜色。详细说明一下,我希望按钮的颜色改变它在墨水飞溅中的作用方式,墨水飞溅颜色的差异实际上会改变按钮的颜色。
就像上面的 gif 一样,当用户按下按钮时,由于墨水飞溅,按钮的颜色会发生变化,但是当用户停止按下按钮时,它会恢复到正常颜色。我知道我可以在onPressed
方法中更改实际按钮的颜色,但这并没有给我想要的飞溅效果。一个例子可能是:
对我来说有点难以解释,因为我无法真正表达我的意思。随时发表评论以获得进一步的解释。
解决方案
我通常使用平面按钮来实现这种高亮颜色效果:
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
),
推荐阅读
- swift - 如何使用 Firebase 上游消息发送可操作(丰富)通知?
- scala - Spark中按日期和小时的交叉表
- sql - SQL date_part 返回本地时区而不是参数中的时区
- r - 如何创建在调用时填充空数据框的函数循环
- python - 通过查找值是否在列表中来删除整个嵌套字典
- git - 无法推送到克隆的仓库
- amazon-s3 - Alpakka s3`multipartUpload`不上传文件
- django - Django sessionid 从 cookie 中消失,用户变为匿名
- laravel - 使用中间件重定向到命名路由会导致找不到页面
- node.js - nodejs apache htaccess 配置问题