首页 > 解决方案 > 如何制作透明的应用栏?

问题描述

return Scaffold(
  backgroundColor: Color(0xfff2edd7),
  appBar: AppBar(
    backgroundColor: Color(0x00000000),
    elevation: 0,
  ),
  drawer: _drawer(),
  body: SingleChildScrollView(
    child: Column(
      children: <Widget>[
        Stack(
          children: <Widget>[
            Container(
              height: size.height * 0.3+100,
              decoration: BoxDecoration(
                  gradient: LinearGradient(
                      begin: Alignment.topCenter,
                      end: Alignment.bottomCenter,
                      //stops: [0.1, 0.6, 1],
                      colors: [Color(0xff4165a4), Color(0xff6573a4), Color(0xffa28aa5),Color(0xffccaaa7),Color(0xfff2edd7)])),
            ),

这是我的部分代码,我想通过具有渐变颜色的容器的颜色来改变 appbar 的颜色。

如果我将body部分定位在appbar部分之上,会解决吗?

标签: flutter

解决方案


设置backgroundColor为透明

  appBar: new AppBar(
          backgroundColor: Colors.transparent,
          elevation: 0.0,
        ),

推荐阅读