[英]Problem with update multiprovider flutter
I recently updated some dependencies of my flutter
application and I had this problem with the multiprovider, could someone guide me on how is the new syntax or what is the problem here?我最近更新了我的flutter
应用程序的一些依赖项,我在 multiprovider 上遇到了这个问题,有人可以指导我新语法如何或这里有什么问题吗?
the previous provider dependency I was working with was ^ 3.0.0 + 1, now it is at 5.0.0我之前使用的提供程序依赖项是 ^ 3.0.0 + 1,现在是 5.0.0
Never post images of your code, we can't copy from it or reproduce it.永远不要发布您的代码图像,我们不能从中复制或复制它。 Here's a setup of some multiproviders in a project I have:这是我拥有的项目中一些多提供者的设置:
Widget build(BuildContext context) {
return MultiProvider(
providers: [
ChangeNotifierProvider<UserState>(create: (ctx) => UserState()),
ChangeNotifierProvider<Cart>(create: (ctx) => Cart()),
ChangeNotifierProvider<LocationProvider>(create: (ctx) => LocationProvider()),
],
child: MaterialApp(theme: ThemeData(
primarySwatch: Colors.blue,
),home: Consumer<UserState>(builder: (context, userState, __) {
if (userState.firstRun) {
userState.getLastUser();
}
return userState.isSignedin ? CustomDrawer(appUser: userState.user) : LoginPageScreen();
}),
),
);
}
There are changes between provider ^3 and ^5, the documentation is pretty decent and does a good job explaining things.提供者 ^3 和 ^5 之间有一些变化,文档相当不错,并且很好地解释了一些事情。 The code I posted is using provider: ^5.0.0
.我发布的代码使用provider: ^5.0.0
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.