add custom boxshadow to Flutter card

前端 未结 3 2082
误落风尘
误落风尘 2020-12-29 06:07

I\'ve implemented cards in a Flutter app. I need a custom BoxShadow for every card. How can this be done?

What I\'ve tried so far is to add the Bo

3条回答
  •  萌比男神i
    2020-12-29 06:27

    The Card Widget doesn't have decoration property so you need to make a card inside a Container and then apply the BoxShadow to the Container,

    Sample :

    class MyCard extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return new Container(
          child: new Card(
            child: new Center(
              child: new Icon(
                Icons.refresh,
                size: 150.0,
              ),
            ),
          ),
          decoration: new BoxDecoration(
            boxShadow: [
              new BoxShadow(
                color: Colors.black,
                blurRadius: 20.0,
              ),
            ],
          ),
        );
      }
    }
    

提交回复
热议问题