After I added the dependency of ProfileLogic
to LocationLogic
I get the following error when the app starts:
I/flutter (14674): A LocationLogic was used after being disposed.
I/flutter (14674): Once you have called dispose() on a LocationLogic, it can no longer be used.
These are my providers:
providers: [
ChangeNotifierProvider(builder: (_) => ConnectivityLogic()),
ChangeNotifierProxyProvider<ConnectivityLogic, ProfileLogic>(
builder: (context, connectivity, previousMessages) =>
ProfileLogic(connectivity.isOnline),
initialBuilder: (BuildContext context) => ProfileLogic(false),
),
ChangeNotifierProxyProvider<ProfileLogic, LocationLogic>(
builder: (context, profileLogic, previousMessages) =>
LocationLogic(profileLogic.profile),
initialBuilder: (BuildContext context) => LocationLogic(null),
),
ChangeNotifierProvider(builder: (_) => SignUpModel()),
ChangeNotifierProxyProvider<ConnectivityLogic, WorkLogic>(
builder: (context, connectivity, previousMessages) =>
WorkLogic(connectivity.isOnline),
initialBuilder: (BuildContext context) => WorkLogic(false),
),
ChangeNotifierProvider(builder: (_) => OrderLogic()),
]
The strange thing is that everything works properly, even with that error.
dispose method Null safety Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener will throw after the object is disposed). This method should only be called by the object's owner.
I think you disposed of a widget that holds those providers. Try to move desired providers higher in the tree. So if you have:
MaterialApp(
home: MultiProvider(
providers: [...],
child: child,
)
)
Do something like:
MultiProvider(
providers: [...],
child: MaterialApp(
home: child,
)
)
If this won't help you need to provide more context. eg. Whats widget tree like.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With