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
m3 material not being elevated #102296
Comments
Hi @cedvdb, Thanks for filing the issue. I am not sure I understood the issue, Can you please clarify what exactly the issue is? |
In the repro the elevated material at the bottom should be elevated but it is not on the apps running on the right which are running with the useMaterial3 flag. The shadows are not seen. You cannot clearly see the elevation if you compare it to those on the left. |
Yes what is in the red circle is not elevated on the right. Is it clearer now ? In your red circles there is no shadow behind the elevated material. Behind the blue circle there is a shadow as you said. In other words the overlay button is a |
Hi @cedvdb This is intended behavior when enabling flutter/packages/flutter/lib/src/material/material.dart Lines 255 to 269 in 0cbd623
Here shadow color is transparent when
You can provide shadow color from the theme, Card widget now does the same thing
useMaterial3
minimal code sampleimport 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key, this.dark = false});
final bool dark;
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Row(
children: [
Expanded(
child: MaterialApp(
debugShowCheckedModeBanner: false,
themeMode: dark ? ThemeMode.dark : ThemeMode.light,
theme: ThemeData(
useMaterial3: false,
brightness: Brightness.light,
colorSchemeSeed: const Color(0xff6750a4),
),
darkTheme: ThemeData(
useMaterial3: false,
brightness: Brightness.dark,
colorSchemeSeed: const Color(0xff6750a4),
),
home: Example(title: 'Material 2'),
),
),
Expanded(
child: MaterialApp(
debugShowCheckedModeBanner: false,
themeMode: dark ? ThemeMode.dark : ThemeMode.light,
theme: ThemeData(
useMaterial3: true,
brightness: Brightness.light,
colorSchemeSeed: const Color(0xff6750a4),
),
darkTheme: ThemeData(
useMaterial3: true,
brightness: Brightness.dark,
colorSchemeSeed: const Color(0xff6750a4),
),
home: Example(title: 'Material 3'),
),
),
],
),
);
}
}
class Example extends StatelessWidget {
Example({super.key, required this.title});
String title;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
const Card(
child: Padding(
padding: EdgeInsets.all(8.0),
child: Text('Card'),
),
),
OverlayButton(
onTap: () {},
child: const Text('Material'),
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {},
child: const Icon(Icons.add),
),
);
}
}
class OverlayButton extends StatelessWidget {
final Function() onTap;
final Widget child;
const OverlayButton({
Key? key,
required this.onTap,
required this.child,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Material(
type: MaterialType.card,
color: Theme.of(context).colorScheme.surface,
elevation: 3,
borderRadius: BorderRadius.circular(20),
shadowColor: Theme.of(context).colorScheme.shadow,
surfaceTintColor: Theme.of(context).colorScheme.surfaceTint,
child: InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(20),
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 8,
),
child: DefaultTextStyle(
style: TextStyle(color: Theme.of(context).colorScheme.onSurface),
child: child,
),
),
),
);
}
}
Closing as this is working as intended. |
Hey @TahaTesser Thanks for the detailed answer. As I understand it has to be done on a case by case basis now, instead of being done for you automatically and you cannot add that to the AppTheme. I was under the wrong impression that when turning useM3 flag to true I'd have the same app with all the bells and whistles from m3. I was a bit taken aback by how our app looked like when I turned on this flag as I had high hopes. Now I understand that it needs some migration. |
@cedvdb
cc: @HansMuller |
@TahaTesser FYI the context menu do not have shadows, in the Figma file furnished by material there are shadows for the menu. Maybe that's a mistake. |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
repro: https://github.com/cedvdb/flutter_repros/tree/m3_material_elevation
The repro has to be run on a big screen because it has the same app running 12 times side by side with different Theme constructors. In the repro the elevated material at the bottom should be elevated but it is not in m3.
The text was updated successfully, but these errors were encountered: