Inkwell not showing ripple when used with Container decoration

后端 未结 5 1827
情歌与酒
情歌与酒 2021-01-31 18:35

I want to add a ripple on an item, it is working fine until I add a gradient on the item using BoxDecoration.

Widget build(BuildContext context) {
          


        
5条回答
  •  名媛妹妹
    2021-01-31 18:49

    Splash color is overlap by container BoxDecoration

    Try this

      Widget build(BuildContext context) {
       return new Container(
          decoration: BoxDecoration(
          borderRadius: new BorderRadius.all(new Radius.circular(4.0)),
          gradient: LinearGradient(
            begin: AlignmentDirectional.bottomStart,
            end: AlignmentDirectional.topEnd,
            tileMode: TileMode.repeated,
            colors: [
              Colors.yellow[800],
              Colors.yellow[700],
            ],
          ),
          boxShadow: [
            new BoxShadow(
                color: Colors.grey[50],
                //blurRadius: 0.3,
                blurRadius: 6.0,
                offset: new Offset(0.0, 4.0)
            )
          ]
      ),
      margin: EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0),
      child: Material(
        color: Colors.transparent,
        //shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(4.0)),
        //elevation: 6.0,
        //shadowColor: Colors.grey[50],
        child: InkWell(
          splashColor: const Color(0x8034b0fc),
          onTap: () {},
          child: Container(
            //decoration: ,
            padding: EdgeInsets.all(16.0),
            child: Text(
              'Click',
              style: TextStyle(
                fontSize: 20.0,
                color: Colors.white,
              ),
            ),
          ),
        ),
      ),
     );
    }
    

提交回复
热议问题