我正在开发 Flutter 应用程序,我想使用
AppBar
和 elevation
属性向 shadowColor
添加阴影。然而,当我设置这些时,AppBar
的背景颜色似乎略有变化,即使我已明确将 backgroundColor
设置为 Colors.white
。
滚动行为工作正常,并且滚动页面时显示正确的背景颜色。但是当应用
elevation
和 shadowColor
时,背景颜色看起来不同。
这是我用于我的
AppBar
的代码:
AppBar(
backgroundColor: Colors.white,
scrolledUnderElevation: 0,
elevation: 1.0,
shadowColor: const Color.fromRGBO(0, 0, 0, 0.25),
)
尽管将
backgroundColor
设置为 Colors.white
,但在应用高程和阴影时,背景看起来会稍微偏离。
AppBar
在显示阴影时应保持白色背景。AppBar
的背景颜色略有变化。如何确保
AppBar
保持其背景颜色(纯白色),同时仍显示 elevation
和 shadowColor
的阴影效果?
将
surfaceTintColor
设置为 Colors.transparent
AppBar(
backgroundColor: Colors.white,
scrolledUnderElevation: 0,
elevation: 1.0,
shadowColor: const Color.fromRGBO(0, 0, 0, 0.25),
surfaceTintColor: Colors.transparent,
)