Flutter Dark Mode using ThemeData
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.
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.