[英]How can I make InkWell's splash visible?
Environment环境
Question问题
I made code like this below.我在下面编写了这样的代码。
I find when I tap it, 'InkWell.onTap' shows up in the console, but splash animation (= the animation expanding like a wave) does not happen.我发现当我点击它时,控制台中会显示“InkWell.onTap”,但不会发生飞溅 animation(= animation 像波浪一样扩展)。 Could you help me understand why I cannot see splash animation?
你能帮我理解为什么我看不到飞溅 animation 吗?
Sample样本
InkWell(
splashColor: Colors.blueAccent,
onTap: () {
print('${DateTime.now()}| InkWell.onTap');
},
child: Container(
color: Colors.lightBlue[100],
child: Row(
children: <Widget>[
Expanded(
child: Column(
children: <Widget>[
Padding(
padding: EdgeInsets.all(8.0),
child: Container(
decoration: BoxDecoration(
color: Colors.lightBlue[50],
border: Border.all(),
),
child: Padding(
padding: EdgeInsets.all(8.0),
child: Align(
alignment: Alignment.centerLeft,
child: Text('Text1'),
),
),
),
),
Padding(
padding: EdgeInsets.only(
left: 16, top: 8, right: 8, bottom: 8),
child: Align(
alignment: Alignment.centerLeft,
child: Text('Text2'),
),
),
],
),
),
],
),
),
)
Additional info附加信息
The code above only makes a light blue square which you can find 5 in the screenshot.上面的代码只制作了一个浅蓝色方块,您可以在屏幕截图中找到 5。
One person suggested this question is a possible duplicate of this .有人建议这个问题可能与此问题重复。 However, I still have a problem.
但是,我仍然有一个问题。
I think the answers basically say that "Move the color
property to outside of InkWell
Widget", but my case has multiple colors ( Colors.lightBlue[100]
and Colors.lightBlue[50]
), so I cannot simply move color
to outside. I think the answers basically say that "Move the
color
property to outside of InkWell
Widget", but my case has multiple colors ( Colors.lightBlue[100]
and Colors.lightBlue[50]
), so I cannot simply move color
to outside. Please correct me if I misunderstand something.如果我误解了什么,请纠正我。
To get the ripple effect a Material
widget must be a direct ancestor of InkWell
with the placement of your InkWell
right now your entire screen would have a ripple effect I am not sure if this is the effect you wanted or not.要获得涟漪效果,
Material
小部件必须是InkWell
的直接祖先,现在您的InkWell
的位置您的整个屏幕都会产生涟漪效果,我不确定这是否是您想要的效果。
Material(
color: Colors.lightBlue[100],
child: InkWell(
splashColor: Colors.blueAccent,
onTap: () {
print('${DateTime.now()}| InkWell.onTap');
},
child: Row(
children: <Widget>[
Expanded(
child: Column(
children: <Widget>[
Padding(
padding: EdgeInsets.all(8.0),
child: Container(
decoration: BoxDecoration(
color: Colors.lightBlue[50],
border: Border.all(),
),
child: Padding(
padding: EdgeInsets.all(8.0),
child: Align(
alignment: Alignment.centerLeft,
child: Text('Text1'),
),
),
),
),
Padding(
padding: EdgeInsets.only(
left: 16, top: 8, right: 8, bottom: 8),
child: Align(
alignment: Alignment.centerLeft,
child: Text('Text2'),
),
),
],
),
),
],
),
),
),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.