I have application that have one screen with Drawer
. Main screen contains following AppBar
:
AppBar(
foregroundColor: Colors.white,
backgroundColor: Colors.green,
elevation: 0,
actions: // actions here
)
I want to keep the AppBar
because of actions I have here. However, I do not want it to have any color. So I have added following code to the app Scaffold
:
extendBodyBehindAppBar: true,
It works well, now the AppBar
is invisible, and the actions are visible. However, when I do something in the drawer and I close it, the AppBar starts to have strange color (not everytime). I have found out that it is still transparent, but something happened with the elevation
, so it acts now like it has elevation: 1.0
. Can somebody advise, how to solve this strange behavior? I think there might be problem with zero elevation
for the both AppBar
and the rest of the screen, and when Drawer
comes above the screen and then closes, the equal elevations collide and therefore it sometimes changes AppBar
. The best solution would be to be available to remove any mask/additional effect that is made on AppBar
, when it have elevation: 1
. Therefore, if I increase the elevation in AppBar
and hide all effects, the AppBar
would be truly transparent in any cases. Thank you for your help.
2
Answers
The "strange color" is actually
surfaceTintColor
, which makes the app bar tinted when using Material 3. To remove it, set it to transparent:To enable elevation shadow as it was in Material 2, see this post:
After upgrading to Flutter 3.16, the app bar, background color, button size, and spaces change
App bar elevation and color change
#flutter
#dart