在flutter中使用Provider在路由之间传递数据的最佳方法是什么?

时间:2020-08-01 18:11:50

标签: flutter dart routes provider

我刚开始使用Provider程序包,并且已经在同一屏幕(/状态)上传递了基本数据。

但是我遇到问题使用提供程序包将数据从一个屏幕(路由)传递到另一屏幕 如果有人可以对此进行更多说明,我将不胜感激。

1 个答案:

答案 0 :(得分:0)

    MultiProvider(
    providers: [
      ChangeNotifierProvider(
        create: (context) => Loader(),
      ),
      ChangeNotifierProvider(create: (context) => SplashBlock()),
      ChangeNotifierProvider(create: (context) => TermsBlock()),
      ChangeNotifierProvider(create: (context) => InitialBlock()),
      ChangeNotifierProvider(create: (context) => HomeBlock()),
      ChangeNotifierProvider(create: (context) => AboutusBlock()),
      ChangeNotifierProvider(create: (context) => EntryBlock()),
      ChangeNotifierProvider(create: (context) => AllEventBlock())
    ],
    child:  MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Flutter',
   
      theme: ThemeData(
        fontFamily: 'OpenSans',
        primaryColor: Colors.white,
        primarySwatch: Colors.blue,
      ),
      home:
      
       Scaffold(
         
         body:SplashScreen()
          ),
     
      onGenerateRoute: Router.generateRoute,
    ));


 Try with multiple provider . You can use data anywhere in-app.