I'm new to flutter and I'm trying to create an app with provider. I wrapped MaterialApp widget with the ChangeNotifierProvider and the app works and I can use the provider as it intended to do. I need to know is it okay to do so and will i face any problems?
Widget build(BuildContext context) {
return ChangeNotifierProvider<BaseModel>(
builder: (context) =>
BaseModel(loading: false, title: "Title", isLoggedIn: false),
child: MaterialApp(
routes: <String, WidgetBuilder>{
"/home": (BuildContext context) => Home(),
"/signIn": (BuildContext context) => SignIn()
},
initialRoute: "/signIn",
title: 'Flutter Demo',
theme: ThemeData(
// is not restarted.
primarySwatch: Colors.blue,
),
home: SignIn()),
);
In all the sample codes they use Provider under "home" in MaterialApp widget. I used MaterialApp inside the provider.
It is totally fine. There's no problem whatsoever.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With