首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >颤振卡片高度不适用于卡片顶部

颤振卡片高度不适用于卡片顶部
EN

Stack Overflow用户
提问于 2021-12-01 06:35:05
回答 2查看 230关注 0票数 0

在卡片小工具中添加容器时,卡片的提升不会应用于卡片的顶部。

代码语言:javascript
复制
Card(
  elevation: 10,
  shadowColor: Colors.green,
  shape: RoundedRectangleBorder(
    borderRadius: BorderRadius.circular(12.0),
  ),
  child: Column(
    children: <Widget>[
      Container(
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            // widget goes here
          ],
        ),
      ),
      SizedBox(
        height: 20,
      ),
      // some more widgets
    ],
  ),
);
EN

回答 2

Stack Overflow用户

发布于 2021-12-01 12:42:56

考虑使用容器装饰而不是卡片提升

代码语言:javascript
复制
return Container(
  margin: EdgeInsets.all(50),
  decoration: BoxDecoration(
    color: Colors.white,
    borderRadius: BorderRadius.all(Radius.circular(12)),
    boxShadow: [
      BoxShadow(
        color: Colors.green.withOpacity(0.5),
        spreadRadius: 5,
        blurRadius: 7,
        offset: Offset(0, 3), // changes position of shadow
      ),
    ],
  ),
child:Column(), //your widget here
)
票数 0
EN

Stack Overflow用户

发布于 2021-12-01 17:07:15

代码语言:javascript
复制
      @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
          child: Align(
        alignment: AlignmentDirectional.topCenter,
        child: Container(
          height: 200,
          width: 200,
          child: Card(
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: [
                Container(
                  color: Colors.cyan,
                  child: Row(
                    mainAxisSize: MainAxisSize.min,
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Text("SOMETHING")
                      // widget goes here
                    ],
                  ),
                ),
              ],
            ),
            color: Colors.orange,
            elevation: 10,
            shadowColor: Colors.green,
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(12.0),
            ),
          ),
        ),
      )),
    );
  }

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70179989

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档