如何修复列制作空白并忽略颤动中的线性渐变

How to fix the column making whitespace and ignoring my linear gradient in flutter

我有一个带有线性渐变的容器,用作我的应用程序的背景色。当我将 Column 作为子项时,我的背景仅在列大小中发挥作用。剩下的space得到一个白色的space。

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

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

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

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')
              ],
            ),
          ),
        ],
      ),
    );
  }