InkWell not showing ripple effect

后端 未结 13 741
陌清茗
陌清茗 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 01:59

    A better way is to use the Ink widget instead of any other widget.

    Instead of defining color inside container you can define it in Ink widget itself.

    Below code will work.

    Ink(
      color: Colors.orange,
      child: InkWell(
        child: Container(
          width: 100,
          height: 100,
        ),
        onTap: () {},
      ),
    )
    

    Do not forget to add a onTap: () {} in the InkWell else it will not show the ripple effect too.

提交回复
热议问题