Created
December 19, 2021 21:19
-
-
Save Roaa94/c96049fa5ebaa1321e3861ca2fd342fe to your computer and use it in GitHub Desktop.
Theme & Primary Color Switcher's App Widget
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class App extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MultiProvider( | |
providers: [ | |
ChangeNotifierProvider( | |
create: (_) => ThemeProvider() | |
), | |
], | |
child: Consumer<ThemeProvider>( | |
child: HomePage(), | |
builder: (c, themeProvider, child) { | |
return MaterialApp( | |
debugShowCheckedModeBanner: false, | |
themeMode: themeProvider.selectedThemeMode, | |
theme: ThemeData( | |
brightness: Brightness.light, | |
primarySwatch: AppColors.getMaterialColorFromColor(themeProvider.selectedPrimaryColor), | |
primaryColor: themeProvider.selectedPrimaryColor, | |
), | |
darkTheme: ThemeData( | |
brightness: Brightness.dark, | |
primarySwatch: AppColors.getMaterialColorFromColor(themeProvider.selectedPrimaryColor), | |
primaryColor: themeProvider.selectedPrimaryColor, | |
), | |
home: child, | |
); | |
}, | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment