Flutter Dark Mode using ThemeData

Mohammad Shohag
Jun 27, 2021

How to turn on Flutter Dark Mode feature using themeData. Today we will learn how to use Flutter ThemeData. It will help us to turn on Dark mode and light mode and also a system-based mode that is based on devices on flutter apps. Here is how to do that.

flutter dark mode
Flutter Dark Mode

Inside MaterialApp() we will use ThemeData and set dark or light mode.

return MaterialApp(
theme: ThemeData(
brightness: Brightness.light,
),
darkTheme: ThemeData(
brightness: Brightness.dark,
),
themeMode: ThemeMode.system,
home: HomePage(),
);

Here on this code,

theme data brightness light is normal and when we add darkTheme brightness dark then the total flutter app turns into the dark theme.

But if you want to use dark or light depending on System mode then we have to add themeMode to the system.

That's it for today it's so easy and simple.

--

--

Mohammad Shohag

I write about Programming, Tech, SEO, ASO, SMM, Business Idea, Travel and many more things.