如何在Flutter中更改波纹效果的颜色?
答案 0 :(得分:2)
@CopsOnRoad答案的示例。 (如按钮)
Theme(
data: ThemeData(splashColor: Colors.red[200]),
child: Material(
elevation: 0,
shape: CircleBorder(),
clipBehavior: Clip.hardEdge,
color: Colors.transparent,
child: InkWell(
child: Padding(
padding: const EdgeInsets.all(10),
child: Icon(
Icons.favorite,
color: _isLiked ? Colors.red : Colors.black12,
size: 20,
),
),
onTap: () {
if(_isLiked){
setState(() {
_isLiked = false;
//You backend state manage code
});
}else{
setState(() {
_isLiked = true;
//You backend state manage code
});
}
},
),
),
)
答案 1 :(得分:0)
将小部件包装在Theme
中,并将data
提供为
data: ThemeData(splashColor: Colors.red)