Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

remove elevation in dark mode (flutter)

I’m developing a flutter application that I need to add theme in, a already handled some problems but I have problem with elevation because in the light mode the containers in body have elevation like this (light mode):

app screen1 (light mode)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

but when switching to the dark mode its’s like this and the elevation is not looking nice

what I need is this (without elevation):
app screen2 (dark mode)

but what I get is this:
app screen3 (dark mode)

>Solution :

For Card you can check the theme mode and do.

Card(
  elevation:
      Theme.of(context).brightness == Brightness.dark ? 0 : 1,
),

or on material app.

return MaterialApp(
  debugShowCheckedModeBanner: false,
  home: TABProv(),
  darkTheme: ThemeData.dark().copyWith(
    cardTheme: Theme.of(context).cardTheme.copyWith(elevation: 0),
  ),
);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading