we have a Location bloc for current location, and we run a location subscription as far after every specific interval we receive current location values.
When we move on to another screen where we don't want to have location of user, or some how improve the usability we need to close service.
We can't dispatch an event for this in dispose of the Bloc.
@override
void dispose() {
_dispose();
super.dispose();
}
if you have your bloc provider around the specific area where you need it, then it already disposes of the bloc once that area is disposed
Hi @dev-shanghai 馃憢
Thanks for opening an issue!
Regarding your question, as @bigworld12 mentioned, if you're using BlocProvider to provide your LocationBloc like:
BlocProvider(
builder: (context) => LocationBloc(),
child: MyChild(),
)
then BlocProvider will handle automatically disposing the bloc for you so you don't need to do anything.
Hope that helps 馃憤
Thank you guys for providing correct and in accordance information.
@felangel Thanks for such useful information!
Most helpful comment
Hi @dev-shanghai 馃憢
Thanks for opening an issue!
Regarding your question, as @bigworld12 mentioned, if you're using
BlocProviderto provide yourLocationBloclike:then
BlocProviderwill handle automatically disposing the bloc for you so you don't need to do anything.Hope that helps 馃憤