Last active
September 6, 2019 17:41
-
-
Save icatalud/082cca82d74943e308e57379bffc1059 to your computer and use it in GitHub Desktop.
Adds a lock to the fetch function.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _fetching = false; | |
fetchAndUpdateImage([String url = 'https://picsum.photos/300/200']) async { | |
if(_fetching) { | |
return; | |
} | |
_fetching = true; | |
final response = await http.get(url); | |
floop['image'] = TransitionImage(Image.memory(response.bodyBytes)); | |
_fetching = false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment