【问题标题】:Flutter 3 Transparent AppBar with transparent shadowColor is still visibleFlutter 3 Transparent AppBar with transparent shadowColor 仍然可见
【发布时间】:2022-10-09 04:24:25
【问题描述】:

我正在尝试使用透明的 AppBar 制作屏幕布局,该 AppBar 必须在其下滚动内容。

问题是,当内容滚动时,AppBar 会显示一个阴影,shadowColor,但它设置为透明色。

编辑:我注意到造成这种情况的原因是在我的应用程序主题中将 useMaterial3 设置为 true。

我正在使用 Flutter 3.0.2。

这是我的代码:

Stack(
        fit: StackFit.expand,
        children: [
          //AuthBackground(),
          Container(color: Colors.brown,),
          Theme(
            data: AppStyles.mainDarkTheme.copyWith(
              textTheme: AppStyles.mainDarkTheme.textTheme.apply(
                bodyColor: Colors.blue,
                displayColor: Colors.blue,
              )
            ),
            child: Scaffold(
              backgroundColor: Colors.transparent,
              extendBodyBehindAppBar: true,
              appBar: AppBar(
                backgroundColor: Colors.transparent,
                shadowColor: Colors.transparent,
                elevation: 0.0,
                bottomOpacity: 0.0,
              ),
              body: _content(),
            ),
          ),
        ],
      )

在这里,您可以看到滚动内容时 AppBar 上的阴影:

提前致谢!

【问题讨论】:

    标签: flutter flutter-layout


    【解决方案1】:

    最后我得到了它。

    我在这个post 上回答了自己:

    我有同样的问题。

    就我而言,我有一个带有透明背景的 AppBar 和一个脚手架 将 extendBodyBehindAppBar 设置为 true。

    我用 Colors.transparent 尝试了 shadowColor 和 surfaceTintColor 值,但阴影仍然可见。

    然后我注意到 AppBar 的 scrolledUnderElevation 属性。环境 它到 0.0 是解决方案。

    【讨论】:

      【解决方案2】:

      设置海拔 = 0 对我有用

        appBar: AppBar(
          elevation: 0,
          backgroundColor: Colors.transparent,
          shadowColor: Colors.transparent,
      

      【讨论】:

        猜你喜欢
        • 2015-04-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-08-02
        • 2014-05-13
        • 1970-01-01
        • 1970-01-01
        • 2014-06-27
        相关资源
        最近更新 更多