颤振:为完整背景应用一个渐变

问题描述 投票:0回答:1

如何将here等渐变应用到应用程序背景?您是否可以看到渐变向下移动应用栏和脚手架主体就像它们是一个小部件而不是两个小部件,每个小部件都有自己的颜色?

flutter
1个回答
1
投票

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

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,)
              ],
            ),
          ),
        ),
      ],
    ),
  )
© www.soinside.com 2019 - 2024. All rights reserved.