I have a Future that is called in the initState(), it makes an http request and saves data in Model class.
It needs to be called very first because there are other streams waiting to for it to get the data so they can rebuild themselves.
But the problem is if I push and quickly pop the route few seconds later I can still see the Future printing response logs which I wrote to it to execute when it's completed. That means the process was active in the background right?
How do I structure my project so that as the route is popped it forcefully terminates the Future request?
@override
void initState() {
// TODO: implement initState
super.initState();
wrapperMovieBloC();
}
void wrapperMovieBloC() async {
//wait till get data is complete
await movieBloc.getContentDetails();
//now we have data such as rating,genres
//I can invoke correspedoning methods which will rebuild themselves
movieBloc.buildRatings();
movieBloc.getGenreList();
}
@override
void dispose() {
// TODO: implement dispose
super.dispose();
movieBloc.dispose();
}
I'm using BloC pattern not with any community based Bloc providers packages just trying to follow the main theory of bloc pattern.