颤振 :应用一个渐变以获得完整背景



如何将像这里这样的渐变应用于应用程序背景?你能看到应用栏和脚手架主体上的渐变向下移动,就像它们是一个小部件而不是两个每个都有自己的颜色的小部件一样吗?

您需要

使用容器作为脚手架的背景来添加渐变。您也可以使用"不透明度"小部件使容器或任何小部件透明。但这是您正在寻找的确切解决方案:

Scaffold(
  body: Container(
    height: MediaQuery.of(context).size.height,
    width: MediaQuery.of(context).size.width,
    decoration: BoxDecoration(
      gradient: LinearGradient(
          colors: [Color(0xFF282a57), Colors.black],
          begin: Alignment.topCenter,
          end: Alignment.bottomCenter),
    ),
    child: Column(
      children: <Widget>[
        Padding(
          padding: const EdgeInsets.fromLTRB(20, 50, 20, 0),
          child: Container(
            child: Row(
              children: <Widget>[
                Icon(Icons.menu,color: Colors.white,),
                Spacer(),
                Text("Expense",style: TextStyle(color: Colors.white,fontSize: 18,)),
                Spacer(),
                Icon(Icons.clear, color: Colors.white,)
              ],
            ),
          ),
        ),
      ],
    ),
  )

最新更新