Member-only story
Design Tricks, Cache Asset Images
Yeah, I am the nut somewhat preparing code and flutter apps for writing three books concurrently. Part of the problem of the flutter docs cookbook is that it’s not more design focused. In this article, I show how to cache asset images so that they are preloaded when the app stats up.
How To Pre-Cache Asset Images
Let me explain asset bundles. The default asset caching of the flutter SDK only works with text structural objects, i.e. non-binary objects. And, images in the asset folder are binary, thus we need to implement a solution. For that we are going to use part of SchedulerBinding API, specifically this:
What that allows us to do is have the WidgetsFlutterBinding wait until it’s fully initialized and when that happens then call what we put in the addPostFramewCallback function(method):