Reputation: 1410
Using Material3 useMaterial3: true
in Flutter version 3.0.1, when scrolling lets say listview, the appbar changes to darker color... Can this be disabled?
Example from native android Material3 MaterialToolbar disable coloring at scroll:
Upvotes: 111
Views: 43451
Reputation: 1176
Instead of putting scrolledUnderElevation: 0.0
in every Appbar
separately, you can use this property in ThemeData
as follows and it's gonna reflect in the whole app.
void main() {
runApp(
const MaterialApp(
theme: ThemeData(
appBarTheme: AppBarTheme(
scrolledUnderElevation: 0.0,
),
),
home: const MyHomePage(),
),
);
}
Upvotes: 4
Reputation: 11
The easiest one liner for me has been
forceMaterialTransparency: true,
on the AppBar widget
Upvotes: 0
Reputation: 359
Best solution is to change the following property in AppBar
scrolledUnderElevation: 0
Upvotes: 9
Reputation: 61
forceMaterialTransparency: true,
surfaceTintColor: Colors.transparent,
Works for API 34 on Pixel 8.
Upvotes: 6
Reputation: 383
The simplest way is useMaterial3: false
in MaterialApp
MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
useMaterial3: false,
),
);
Upvotes: -2
Reputation: 31
However, this question has been already answered. But as you can see there different ways to do it. I would like to point out a little difference since I got a little confused in the beginning, and that is, Though both the solutions work but are different
appBar: AppBar(
scrolledUnderElevation: 0.0,
title: Title
),
In the above case, you can have a different color for the scaffold, and the AppBar
appBar: AppBar(
forceMaterialTransparency: true,
title: Title
),
In the above case doesn't matter if you have a separate color for the AppBar, it will make your AppBar transparent in terms of color,
Upvotes: 0
Reputation: 1
As other have pointed out setting the scrolledUnderElevation
to 0.0 on the concerned AppBar
widget solves the issue.
Upvotes: 0
Reputation: 119
appBar: AppBar(
scrolledUnderElevation: 0.0, // This will fix the problem
title: Title
),
Upvotes: 11
Reputation: 1372
Overriding defaultScrollNotificationPredicate
of an AppBar
also seems to reach the desired behavior, i.e:
AppBar(
notificationPredicate: (_) => false,
...
)
Upvotes: 4
Reputation: 21
Use the AppBar's property surfaceTintColor: Colors.transparent,
to disable the "recoloring".
You can set it as a property of the AppBar
widget for each app bar.
Or better yet, override the surfaceTintColor
in the AppBarThemeData
property of ThemeData
when setting the global theme of the app. This way you can set the property for all AppBars in your app.
Upvotes: 1
Reputation: 11
surfaceTintColor: Colors.transparent; This works for instead of adding to every appbar of page add it in appbar
appBarTheme: const AppBarTheme( backgroundColor: Colors.transparent, surfaceTintColor: Colors.transparent, ),
Upvotes: 0
Reputation: 1204
I think this is the best solution mostly with the material3 flutter
scrolledUnderElevation: 0,
to disable it completely just make sure it is 0 incase you just want to reduce the opacity just increase the value i.e 0.6
Upvotes: 33
Reputation: 1844
It works for me:
surfaceTintColor: Colors.transparent; // add required color
Either add in the appBar
or otherwise in the ThemeData
.
Upvotes: 1
Reputation: 327
just add below property to AppBar :
forceMaterialTransparency: true,
problem will solved.
Upvotes: 31
Reputation: 2192
I had same problem.
In my case i had an AppBar
with transparent background and a Scaffold
with extendBodyBehindAppBar
set to true
.
I tried with shadowColor
and surfaceTintColor
with Colors.transparent
value, but the shadow was still visible.
Then I noticed the scrolledUnderElevation
property of AppBar. Setting it to 0.0 was the solution.
Upvotes: 199
Reputation: 769
I think you can just set the surfaceTintColor
property of AppBar
:
surfaceTintColor: Colors.transparent
I was facing this same issue and solved it right after looking at your question.
Upvotes: 76