我觉得给容器加 colored颜色 盖住了墨水的效果
https://api.flutter.dev/flutter/material/InkWell/InkWell.html个
这个代码似乎有效
body: new Center(
child: new Container(
child: new Material(
child: new InkWell(
onTap: (){print("tapped");},
child: new Container(
width: 100.0,
height: 100.0,
),
),
color: Colors.transparent,
),
color: Colors.orange,
),
),
只需单击中间的方块即可.
编辑:我找到了错误报告.https://github.com/flutter/flutter/issues/3782个
这实际上是预期的,尽管我们应该更新文档以使其更清晰.
是这样的,material 说明书上说飞溅的实际上是material 上的墨水.所以当我们飞溅时,我们所做的就是让Material小工具进行飞溅.如果你在material 上面有什么东西,我们会溅到它下面,而你看不到它.
我想添加一个"MaterialMage"小部件,从概念上将其图像打印到material 中,这样飞溅物就会覆盖在图像上.我们可以用一种类似的material 来装饰.或者我们可以让material 本身进行装饰.现在它需要一种 colored颜色 ,但我们可以扩展到整个装饰.不过,目前还不清楚有梯度的material 是否真的符合material 规格,所以我不确定我们是否应该这样做.
在短期内,如果您只需要解决办法,您可以将material 放在容器的顶部,material 设置为使用"透明"类型,然后将墨水很好地放入容器中.
--你好
更新:Hixiego 年合并了一种新的墨水解决方案.墨水提供了一种在图像上飞溅的便捷方式.
testWidgets('Does the Ink widget render anything', (WidgetTester tester) async {
await tester.pumpWidget(
new Material(
child: new Center(
child: new Ink(
color: Colors.blue,
width: 200.0,
height: 200.0,
child: new InkWell(
splashColor: Colors.green,
onTap: () { },
),
),
),
),
);
Material(
color: Colors.grey[800],
child: Center(
child: Ink.image(
image: AssetImage('cat.jpeg'),
fit: BoxFit.cover,
width: 300.0,
height: 200.0,
child: InkWell(
onTap: () { /* ... */ },
child: Align(
alignment: Alignment.topLeft,
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Text('KITTEN', style: TextStyle(fontWeight: FontWeight.w900, color: Colors.white)),
),
)
),
),
),
)
请注意:我没有测试新的墨水小部件.我处理了ink_paint_测试的代码.dart和Ink类文档
https://github.com/Hixie/flutter/blob/1f6531984984f52328e66c0cd500a8d517964564/packages/flutter/test/material/ink_paint_test.dart个
https://github.com/flutter/flutter/pull/13900
https://api.flutter.dev/flutter/material/Ink-class.html