is it okay to supply all the providers on the root widget

Viewed 226

Let's say I have 6 providers. All of which are used in different spots in the app. Is it advisable/logical to make my root widget a MultiProvider whose child is the MaterialWidget and supply all the providers there. Then I can just use them wherever needed without worrying about whether or not they are above that particular widget.

Now I've tried and it works (obvsly). My question is, is it a good practice in terms of performance, code quality, etc?

@override
  Widget build(BuildContext context) {
    return MultiProvider(
      providers: [
        ChangeNotifierProvider(
          create: (ctx) => Authentication(),
        ),
        ChangeNotifierProvider(
          create: (ctx) => Books(),
        ),
        ChangeNotifierProvider(
          create: (ctx) => HomeProvider(),
        ),
        ChangeNotifierProvider(
          create: (ctx) => Renk(),
        ),
      ],
      child: MaterialApp(
0 Answers
Related