Skip to content

Latest commit

 

History

History
62 lines (47 loc) · 2.16 KB

README.md

File metadata and controls

62 lines (47 loc) · 2.16 KB

Switching themes in flutter apps by using provider

Nowadays, switching themes is one of the trending feature in every mobile application. By switching the themes, users can reduce their eye strain and increases mobile battery life.

In Flutter, we can give the Theme across the app by providing the ThemeData to the MaterialApp constructor. The default theme will be shared across the app when no theme is provided.

MaterialApp(
   theme: ThemeData( ... ), // declaring the theme to across the app
);

ThemeData.light() gives the Light blue theme, which is a default theme for every flutter application.

MaterialApp(
  theme: ThemeData.light(),  // default the theme 
);

ThemeData.dark() gives the dark theme across the application

MaterialApp(
   theme: ThemeData.dark(),  // default dark the theme 
);

Instead of using default theme colors, we can provide the own colors to primaryColor, accentColor, backgroundColor … to create a costume theme.

ThemeData(
          accentColor: Colors.red,
          brightness: Brightness.light,
          primaryColor: Colors.amber,
),

For complete article visit this

Output

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.