U A*_*los 9 flutter flutter-animation
在我的应用程序中,我设置了一个 IconButton 来渲染具有彩色背景的 Row。不幸的是,按下按钮时的波纹动画会在 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,
),
),
],
),
),
]));
}
}
Run Code Online (Sandbox Code Playgroud)
Mic*_*ono 11
涟漪是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: () {},
),
),
Run Code Online (Sandbox Code Playgroud)
更新
为了更具体地实现您的目标,您可以将您的替换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(
...
),
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4891 次 |
| 最近记录: |