I was working with flutter, when I made http requests with async and Future, when I executed Future.whenComplete() and printed a message, it is printed infinite number of times, can I stop it's execution
I was working with flutter, when I made http requests with async and Future, when I executed Future.whenComplete() and printed a message, it is printed infinite number of times, can I stop it's execution
You can register as many then, whenComplete, callbacks to a Future as you want. They all will be called when the Future completes.
If you add such a callback when the Future is already completed, the callbacks will be called immediately (in the next microtask as far as I remember).