我一直對漣漪效應有疑問。這是我的小部件:
@override
Widget build(BuildContext context) {
return Material(
color: Colors.transparent,
child: InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(30),
highlightColor: Colors.blue.withOpacity(0.4),
splashColor: Colors.green.withOpacity(0.5),
child: Card(
margin: EdgeInsets.all(0),
child: Container(
color: Colors.orange[100 * (index! % 12 1)],
alignment: Alignment.center,
child: Text(
"test",
style: TextStyle(fontSize: 16),
),
),
),
),
);
}
我在網格視圖中使用:
return Scaffold(
body: SafeArea(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: CustomScrollView(
slivers: [
SliverGrid(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
mainAxisSpacing: 8,
crossAxisSpacing: 8,
childAspectRatio: 1,
),
delegate: SliverChildBuilderDelegate(
(context, index) {
return CategoryItem(
index: index,
onTap: () {
print("clicked");
},
);
},
childCount: 10,
),
)
],
),
),
));
為什么不作業?
uj5u.com熱心網友回復:
用 Ink 小部件包裹卡片。有關墨水的更多資訊
編輯
return Card(
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: () {
print("hi");
},
borderRadius: BorderRadius.circular(30),
highlightColor: Colors.blue.withOpacity(0.4),
splashColor: Colors.green.withOpacity(0.5),
child: Ink(
color: Colors.orange,
child: Container(
//color: Colors.orange,
alignment: Alignment.center,
child: Text(
"test",
style: TextStyle(fontSize: 16),
),
),
),
),
),
);
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/489278.html
上一篇:共享首選項不獲取/保存可變資料
