I am trying to change the theme of my app, but the primary color of my app is green. I've seen so much resolutions but I am got confused how to set a light theme not blue, but green. Should I put inside this line of code the custom primary color or I should put it in the root if my app?
The code:
class ThemeProvider extends ChangeNotifier {
ThemeData _selectedTheme;
Typography defaultTypography;
SharedPreferences prefs;
ThemeData dark = ThemeData.dark().copyWith();
ThemeData light = ThemeData.light().copyWith();
ThemeProvider(bool darkThemeOn) {
_selectedTheme = darkThemeOn ? dark : light;
}
the main:
return MaterialApp(
theme: value.getTheme(),
debugShowCheckedModeBanner: false,
home: MapPage(),
routes: {'favorite': (_) => Homescreen()},
);
CodePudding user response:
As you already have your dark and light ThemeData, you can adjust the primary color there:
final ThemeData darkTheme = new ThemeData.dark().copyWith(
primaryColor: Colors.green
);
With this you can adjust the two themes as you wish.