flutter - 为什么 Flutter IconButton 动画显示在行下
问题描述
在我的应用程序中,我设置了一个 IconButton 来渲染具有颜色背景的 Row。不幸的是,按钮按下时的波纹动画呈现在 Row 下(如截屏视频所示)。我如何在行上显示波纹?
class Card extends StatelessWidget {
final Issue issue;
Color _bgColor;
Card({this.issue}) {
_bgColor = colorSwatch[issue.hashCode % colorSwatch.length];
}
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(top: 12, left: 18, right: 18),
padding: EdgeInsets.only(top: 8, bottom: 8),
decoration: new BoxDecoration(
color: _bgColor,
border: new Border.all(color: _bgColor),
borderRadius: BorderRadius.all(
Radius.circular(10.0)
),
),
child: Row(children: [
IconButton(
padding: EdgeInsets.only(right: 16),
icon: Icon(Icons.play_arrow, color: Colors.white, size: 48),
tooltip: 'Start ${issue.issueName}',
onPressed: () {},
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding: const EdgeInsets.only(bottom: 8),
child: Text(
issue.title,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
softWrap: true,
),
),
Text(
issue.issueName,
style: TextStyle(
color: Colors.white,
),
),
],
),
),
]));
}
}
解决方案
波纹是Material
效果的一部分。用:IconButton
_Material
Material(
color: _bgColor,
child: IconButton(
padding: EdgeInsets.only(right: 16),
icon: Icon(Icons.play_arrow, color: Colors.white, size: 48),
tooltip: 'Start ${issue.issueName}',
onPressed: () {},
),
),
更新
为了更具体地实现您的目标,您可以将您的替换Container
为Material
.
return Material(
color: _bgColor,
borderRadius: BorderRadius.all(Radius.circular(10.0)),
child: Container(
margin: EdgeInsets.only(top: 12, left: 18, right: 18),
padding: EdgeInsets.only(top: 8, bottom: 8),
backgroundBlendMode: BlendMode.multiply,
child: Row(
...
),
);
推荐阅读
- angular - 引导程序的导航药丸不适用于角度
- laravel - 使用警卫登录正在重定向到空白页面
- android - 无法从 Android Studio 中的布局中引用任何 ID
- python - 更改循环提示
- c# - 此类型名称中的 #(哈希)是什么意思?
- php - 我可以通过检查我的数据库有多少行来获得 SQL 注入吗?
- angular - ie11中的Angular ngModel选择
- database - 如何将访问备份为压缩文件?
- javascript - 如何使用 Google Apps 脚本对 SaxoTrader 进行身份验证
- python - 如何将整个numpy数组作为python中的参数传递给用户定义的函数?