首页 文章

将自定义boxshadow添加到Flutter卡

提问于
浏览
3

我在Flutter应用程序中实现了卡片 . 我需要为每张卡定制 BoxShadow . 如何才能做到这一点?

到目前为止我尝试过的是将 BoxShadow 属性添加到 Card() 构造函数中,该构造函数不起作用...

1 回答

  • 3

    Card小工具没有装饰属性,因此您需要在Container中制作一张卡,然后将BoxShadow应用于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,
            ),
          ]),
        );
      }
    }
    

    enter image description here

相关问题