Managing an object's complete lifecycle via Provider is possible:
Provider<LocalStorageManager>(
create: (context) => LocalStorageManager(),
dispose: (context, obj) => obj.dispose(),
),
However, if the object has to be asynchronously initialized, we have to use FutureProvider:
FutureProvider<LocalStorageManager>(
create: (context) async => await LocalStorageManager().initialize(),
),
If FutureProvider has no dispose callback, how should I dispose of LocalStorageManager?
Furthermore, what is the difference with FutureProvider.value if the lifecycle is not managed?