首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何修复在颤动中生成空格并忽略线性梯度的列

如何修复在颤动中生成空格并忽略线性梯度的列
EN

Stack Overflow用户
提问于 2019-06-25 04:50:03
回答 1查看 144关注 0票数 0

我有一个容器与线性渐变的目的,作为我的应用程序的背景颜色。当我把一列作为子元素时,我的背景只在列大小上起作用。剩余的空格是一个空格。

我试过将脚手架的背景颜色设置为透明,但它变成了黑色空间而不是空白空间

代码语言:javascript
复制
Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.transparent,
      body: Container(
          padding: EdgeInsets.all(32),
          decoration: BoxDecoration(
            gradient: LinearGradient(
              begin: Alignment.topCenter,
              end: Alignment.bottomCenter,
              stops: [0.1, 0.9],
              colors: [
                HexColor("#2a4644"),
                HexColor("#3c1630"),
              ],

            ),
          ),
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              Text('test')
            ],
          )
        ),
    );
  }
}

这是它现在的屏幕截图:http://prntscr.com/o64s1f

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-06-25 04:58:27

你必须使用一个堆栈。Container应该占据整个屏幕的宽度和高度。然后将该列放在Container前面。

代码语言:javascript
复制
Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.transparent,
      body: Stack(
        children: <Widget>[
          Container(
            width: double.infinity,
            height: double.infinity,
            decoration: BoxDecoration(
              gradient: LinearGradient(
                begin: Alignment.topCenter,
                end: Alignment.bottomCenter,
                stops: [0.1, 0.9],
                colors: [
                  Color(0xFF2a4644),
                  Color(0xFF3c1630),
                ],
              ),
            ),
          ),
          Padding(
            padding: const EdgeInsets.all(32.0),
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: <Widget>[
                Text('test')
              ],
            ),
          ),
        ],
      ),
    );
  }

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

https://stackoverflow.com/questions/56743766

复制
相关文章

相似问题

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