-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Using precacheImage in initState #9
Comments
Using If we take a look at the implementation of the So in our case we lose the ability to respond to resolution changes. However, as we usually have just a one size of the image, then it's not super problematic. We don't want to invoke precaching in build method as it could be called multiple times, e.g. when resizing the window. I'm not sure if this method is smart enough to not cache the same image multiple times. One potential optimization would be to not precache some variants of images that we have several sizes of (e.g. Wdyt @bselwe? |
Thanks for this issue @cekrozl1! @orestesgaolin It seems that I can see that the recommended approach to use I think it would be okay to move this logic to Let me know what you think. |
Yeah, I think that'd be good solution |
Hi @orestesgaolin, hi @bselwe ! I was only using your project as a template to enhance my own projects structures, and I didn't really expect an enhancement here. But I'm glad to see an improvement. @bselwe, I was the one asking if this specific project was "production-ready" 2 weeks ago here Shout-out to the entire VGV team. I love what you're doing! |
Using precacheImage in initState
Hi!
I read a couple of posts such as https://stackoverflow.com/questions/51343735/flutter-image-preload which say that initState might not be the right place to call precacheImage from, since precacheImage requires the context which is not (or might not be) available from initState.
I see that the puzzle code is using it here : https://github.com/VGVentures/slide_puzzle/blob/release/lib/app/view/app.dart.
I also see that there is no issues running this code.
Is precacheImage in initState appropriate here?
The text was updated successfully, but these errors were encountered: