0

I have the following service structure instead of having a single huge class A:

class A extends ChangeNotifier {
...
}

class B extends A {
...
}

class C extends A {
...
}
class D extends A {
...
}

I can do the following:

 MultiProvider(
      providers: [
        ChangeNotifierProvider(create: (_) => A()),
        ChangeNotifierProvider(create: (_) => B()),
        ChangeNotifierProvider(create: (_) => C()),
        ChangeNotifierProvider(create: (_) => D()),
      ],

But is there any other way to provide all the child classes in one step rather than providing each one separately in a MultiProvider.

Omar Fayad
  • 1,733
  • 3
  • 11
  • 27
  • I think you would have to create a new class to hold all of the instances, and then just provide that. There is not built in dart process for "initialize all child classes" of a certain object, if that is what you are asking. – eimmer Apr 02 '21 at 13:04
  • I tried it already, but it didn't work. – Omar Fayad Apr 02 '21 at 13:10

0 Answers0