当我在flutter中的didChangeDependencies中调用多个提供程序时,它会显示错误

when I call more than one provider in didChangeDependencies in flutter ,it shows me error


当我在flutter中的didChangeDependencies中调用多个提供程序时,它会显示错误 已获得1个解决方法 2020-08-19 07:08:29 flutter

当我在didChangeDependencies中调用多个提供程序时.它向我显示了这个错误 “产品在被处理后被使用,一旦你在产品上调用dispose(),它就不能再使用了.”

主要是我的供应商.达特.

MultiProvider(
      providers: [
        ChangeNotifierProvider(
          create: (context) => Auth(),
        ),
        ChangeNotifierProxyProvider<Auth, Products>(
            create: (_) => Products(null),
            update: (ctx, auth, previousproduct) => Products(auth.userid)
//              previousproduct == null ? [] : previousproduct.items),
            ),
        ChangeNotifierProxyProvider<Auth, AddressData>(
//          create: (context) => AddressData(null,[]),
          update: (Context, auth, previousAddresses) => AddressData(auth.userid,
              previousAddresses == null ? [] : previousAddresses.Addresses),
        ),
        ChangeNotifierProxyProvider<Auth, Orders>(
//          create: (context) => Orders(null, []),
          update: (ctx, auth, previousorders) => Orders(
              auth.userid, previousorders == null ? [] : previousorders.orders),
        ),
        ChangeNotifierProvider(
          create: (context) => Cart(),
        ),
      ],

这是我在homescreen.dart中的didchangedependencies.

void didChangeDependencies() {
    final prod = Provider.of<Products>(context, listen: false);
      // TODO: implement didChangeDependencies
      prod.fetchandsetproduct();
      prod.fetchcategoriesproduct();
      final prod2 = Provider.of<Auth>(context,listen: false);
      prod2.getcurrentuser();
    super.didChangeDependencies();
  }

当我在flutter中的didChangeDependencies中调用多个提供程序时,它会显示错误 方法1

You can call any number of provider

AboutusBlock aboutusBlock;
Loader loader;
HomeBlock homeBlock;
InitialBlock initialBlock;


@override 
void didChangeDependencies() {
super.didChangeDependencies();
final aboutusBlock = Provider.of<AboutusBlock>(context);
final loader = Provider.of<Loader>(context);
final homeBlock = Provider.of<HomeBlock>(context);
final initialBlock = Provider.of<InitialBlock>(context);
if (this.aboutusBlock != aboutusBlock ||
    this.loader != loader ||
    this.homeBlock != homeBlock ||
    this.initialBlock != initialBlock) {
  this.loader = loader;
  this.aboutusBlock = aboutusBlock;
  this.homeBlock = homeBlock;
  this.initialBlock = initialBlock;
  Future.microtask((){
    homeBlock.getHomeConfig(loader, initialBlock);
    aboutusBlock.getAboutUsConfig(loader);});
}
}

.htaccess .net .net-core 2d 3d actions-on-google actionscript-3 activemq acumatica adobe-xd aframe ag-grid air airflow ajax akka alexa algorithm alignment allure amadeus amazon-cognito amazon-deequ amazon-dynamodb amazon-ec2 amazon-redshift amazon-s3 amazon-web-services amcharts amcharts4