Flutter Ripple effect color

北城余情 提交于 2021-01-02 19:15:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!