New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for AppBarTheme.scrolledUnderElevation parameter #109
Comments
Hi @Willian199, thanks for you suggestion. This is potentially something I will add, as support for Material 3 is getting more ready in Flutter. I am currently reviewing what critical changes and additions will be needed when next release of Flutter comes out. From the looks of things in master channel, it will finally have very good M3 support, I might added this then, or in a later release. Meanwhile and as info, you can always adjust any theme returned by FlexColorScheme by doing a The doc FAQ talks about it here https://docs.flexcolorscheme.com/faq#how-do-i-modify-the-component-themes-with-custom-features And some concrete examples are provided in discussions in the these links:
Following those example you can already see how it can be done to set So for class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
final ThemeData lightTheme =
FlexThemeData.light(scheme: FlexScheme.mandyRed, useMaterial3: true);
return MaterialApp(
title: 'Flutter Demo',
theme: lightTheme.copyWith(appBarTheme: lightTheme.appBarTheme.copyWith(
shadowColor: Colors.transparent,
scrolledUnderElevation: 1, // <= Or whatever you want :)
),
),
themeMode: ThemeMode.light,
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
} I put it here to 1 (default is 3 in M3) and the Although I am surprised you are seeing elevation shadow, since the shadow color should already be transparent in M3 to avoid the shadow. Maybe that is not the case in Flutter stable (3.3.x) if you are using that. Master now has these values as default for AppBar theme in M3 mode: class _AppBarDefaultsM3 extends AppBarTheme {
_AppBarDefaultsM3(this.context)
: super(
elevation: 0.0,
scrolledUnderElevation: 3.0,
titleSpacing: NavigationToolbar.kMiddleSpacing,
toolbarHeight: 64.0,
);
final BuildContext context;
late final ThemeData _theme = Theme.of(context);
late final ColorScheme _colors = _theme.colorScheme;
late final TextTheme _textTheme = _theme.textTheme;
@override
Color? get backgroundColor => _colors.surface;
@override
Color? get foregroundColor => _colors.onSurface;
@override
Color? get shadowColor => Colors.transparent;
@override
Color? get surfaceTintColor => _colors.surfaceTint;
@override
IconThemeData? get iconTheme => IconThemeData(
color: _colors.onSurface,
size: 24.0,
);
@override
IconThemeData? get actionsIconTheme => IconThemeData(
color: _colors.onSurfaceVariant,
size: 24.0,
);
@override
TextStyle? get toolbarTextStyle => _textTheme.bodyMedium;
@override
TextStyle? get titleTextStyle => _textTheme.titleLarge;
} So the class _AppBarDefaultsM3 extends AppBarTheme {
_AppBarDefaultsM3(this.context)
: super(
elevation: 0.0,
scrolledUnderElevation: 3.0,
titleSpacing: NavigationToolbar.kMiddleSpacing,
toolbarHeight: 64.0,
);
final BuildContext context;
late final ThemeData _theme = Theme.of(context);
late final ColorScheme _colors = _theme.colorScheme;
late final TextTheme _textTheme = _theme.textTheme;
@override
Color? get backgroundColor => _colors.surface;
@override
Color? get foregroundColor => _colors.onSurface;
@override
Color? get surfaceTintColor => _colors.surfaceTint;
@override
IconThemeData? get iconTheme => IconThemeData(
color: _colors.onSurface,
size: 24.0,
);
@override
IconThemeData? get actionsIconTheme => IconThemeData(
color: _colors.onSurfaceVariant,
size: 24.0,
);
@override
TextStyle? get toolbarTextStyle => _textTheme.bodyText2;
@override
TextStyle? get titleTextStyle => _textTheme.titleLarge;
} However, in version 3.3.x stable It was then changed (based on some feedback and rationale on topic that I wrote), so that to get no shadow, This is a bit confusing to me, in both cases you should no see any shadow on the You should only see the change in Setting Hope this helps with you immediate quick fix needs, and provides some additional background info on it 😄 |
Yes, what you are seeing is the Material 3 elevation tint, not a shadow. When Material elevates in M3, it changes color, you called it a shadow, but a shadow would be a drop shadow under the AppBar, like the red example. The slightly different color on the AppBar, you get when you scroll under it, comes from AppBar being elevated and tint color being applied. This is a default Material3 design and intended in it. It is perhaps not such a good look for your particular use case and design. The correct way to get rid of it, is to set the scroll under elevation to 0. Another way is to set the tint color to transparent, but elevation should be computationally more efficient for the framework. The shadow color only affects the red glow part in your example, and that is already invisible by default in Material 3. I got a bit confused when you called it a shadow, but where actually referring to the elevation tint. Sure one could say it looks a bit like there is shadow on the AppBar, since it gets darker, someone might also say it looks like the transparency scrim on the status bar of the AppBar, but it comes from the elevation of the AppBar and Material getting elevation tint when elevated. Semantics and terminology, yes I agree 😀 Kind regards, Mike |
This feature will be included in the next FlexColorScheme feature release, currently the WIP release version number is 6.2.0 since it contains no breaking changes so far, even if the release will be quite major feature wise. Target is to release it shortly (few days) after the Flutter Forward event on Jan 25th, 2023. |
Still same milestone target, but the release will be called 7.0.0, since I am introducing a few minor default style breaking changes. There are no breaking API changes though. There is a beta of it available on pub if you are feeling experimental, it includes this new property. |
Worked perfectly. |
Final beta of version 7 is out. There will be no additional features or API changes in the stable release. More info in this tweet thread: https://twitter.com/RydMike/status/1637228788139302914?s=20 Closing this feature request as delivered in version7 final beta 😄 |
In my app, I have a list screen where I'm using a GridView.
However, when scrolling the AppBar receives a shadow effect (only happens with material3).
To remove the shadow, I need to set the parameter scrolledUnderElevation = 0.
AppBar( scrolledUnderElevation: 0, ... )
If can set AppBarTheme.scrolledUnderElevation default to zero or a parameter for FlexSubThemesData.
https://github.com/rydmike/flex_color_scheme/blob/master/lib/src/flex_color_scheme.dart#L5894
appBarTheme: AppBarTheme( scrolledUnderElevation: 0, ...)
The text was updated successfully, but these errors were encountered: