InkWell not showing ripple effect

后端 未结 13 731
陌清茗
陌清茗 2020-11-30 01:39

Tapping the container triggers the onTap() handler but does not show any ink splash effect.

class _MyHomePageState extends State

        
13条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-30 02:17

    This is working for me:

    Material(
        color: Colors.white.withOpacity(0.0),
        child: InkWell(
          splashColor: Colors.orange,
          child: Text('Hello'), // actually here it's a Container wrapping an image
          onTap: () {
            print('Click');
          },
        ));
    

    After trying many answers here, it was a combination of:

    1. Setting splashColor
    2. Wrapping InkWell in Material(color: Colors.white.withOpacity(0.0), ..)

    Thanks to the answers here that make those 2 points

提交回复
热议问题