I'm currently using http 0.12.2 package. When I disposed current page the http request still ongoing and didn't stop the request.
Any idea how to stop all request activity when the page already disposed ? Thanks.
I'm currently using http 0.12.2 package. When I disposed current page the http request still ongoing and didn't stop the request.
Any idea how to stop all request activity when the page already disposed ? Thanks.
Flutter usually only complains if you attempt to change some state within the widget after it has been disposed of. You could use the mounted state in order to determine if the widget is mounted before running mutating code.
For example:
void initState() {
super.initState();
http.get(Uri.https('www.googleapis.com', '/books/v1/volumes', {'q': '{http}'})).then((_) {
// This is when dart usually complains if the widget is disposed,
// so let's check if we are 'mounted' first.
if (mounted) {
// Do some mutation
}
});
}
Here is the documentation for mounted.