Skip to content

Instantly share code, notes, and snippets.

@ashishrawat2911
Last active January 13, 2020 09:48
Show Gist options
  • Select an option

  • Save ashishrawat2911/8bbf5740abeb688b7864937a9db6c4cd to your computer and use it in GitHub Desktop.

Select an option

Save ashishrawat2911/8bbf5740abeb688b7864937a9db6c4cd to your computer and use it in GitHub Desktop.
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
DarkThemeProvider themeChangeProvider = new DarkThemeProvider();
@override
void initState() {
super.initState();
getCurrentAppTheme();
}
void getCurrentAppTheme() async {
themeChangeProvider.darkTheme =
await themeChangeProvider.darkThemePreference.getTheme();
}
@override
Widget build(BuildContext context) {
return
ChangeNotifierProvider(
create: (_) {
return themeChangeProvider;
},
child: Consumer<DarkThemeProvider>(
builder: (BuildContext context, value, Widget child) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: Styles.themeData(themeChangeProvider.darkTheme, context),
home: SplashScreen(),
routes: <String, WidgetBuilder>{
AGENDA: (BuildContext context) => AgendaScreen(),
},
);
},
),);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment