Last active
July 29, 2019 13:03
-
-
Save plateaukao/ffc76091e5d6901e220d6ea9bed60840 to your computer and use it in GitHub Desktop.
flutter_load_image_slow.dart
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
@override | |
void initState() { | |
super.initState(); | |
downloadWhenNecessary(); | |
} | |
downloadWhenNecessary({Function action}) { | |
_downloadImage().then((bytes) async { | |
if(!mounted) return; | |
// build an Image Widget from the downloaded image bytes. | |
final image = Image.memory(bytes, fit: BoxFit.contain,); | |
// ask state to build the widget right after Image Widget is created. | |
setState(() { }); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment