问题
How can I change ripple effect color in Flutter?
回答1:
Wrap your widget in Theme
and provide the data
as
data: ThemeData(splashColor: Colors.red)
回答2:
An example for the @CopsOnRoad's answer. (Like-Button)
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
});
}
},
),
),
)
来源:https://stackoverflow.com/questions/53806032/flutter-ripple-effect-color