简体   繁体   中英

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?

the previous provider dependency I was working with was ^ 3.0.0 + 1, now it is at 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. The code I posted is using provider: ^5.0.0 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM