0
votes

how can we register the Providers class with get_it so we just register the Provider once with get_it and that can be used anywhere ? let's say we have AuthProvider and we register it like this,

MultiProvider(
          providers: [
            ChangeNotifierProvider<ProductDataProvider>(
                create: (_) => AuthProvider()),
            ChangeNotifierProvider<AuthenticationProvider>(
                create: (_) => AuthenticationProvider()),
          ],
          child: Container())

so what I want to do is register an AuthProvider provider with get_it and Wrap the MaterialApp with get_it registry method so I can use all of those providers anywhere in the app class.

1

1 Answers

-1
votes

Provider is a widget so it must be in your widget tree.

But I think you are asking if you can get access to the provided data without a context and out side of the widget tree.

I would look at making a class that holds the key data.

The data class would be implemented as a factory.

Then wrap the data class in a provider.

You don't actually need getit given the data class is a factory.