颤动波纹效果颜色

时间:2018-12-16 20:07:23

标签: dart flutter flutter-layout

如何在Flutter中更改波纹效果的颜色?

2 个答案:

答案 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
                        });
                    }
                },
          ),
    ),
)

enter image description here

答案 1 :(得分:0)

将小部件包装在Theme中,并将data提供为

data: ThemeData(splashColor: Colors.red)