Skip to content

satyamparasa15/switching_themes_in_flutter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published