0

I'm making a quiz-type app for Android & iOS, which is art oriented. This means that image resolution is very important. Client provided ~30 images, 25mb each on average. I can probably get away with compressing them to about 4mb each. After that, loss becomes noticeable.

My main problem is that the images (assets) seem to load too slow. Every time the screen changes to the next one, the image needs > 300 ms to show.

Precaching the images doesn't seem to help.

    Widget build(BuildContext context) {
      precacheImage(Image.asset(data["painting-location"]).image, context);
      return Scaffold(
        appBar: null,
        backgroundColor: Color(bgColor),
        body: ...
          PinchZoomImage(image: Image.asset(data["painting-location"]),),
        ...
      );
    }

I have also tried precaching in didChangeDependencies() but i get the same result.

Are the images just too large, or am I missing something as far as precaching goes?

UPDATE I got away with compressing the images to less than 500 kb each and loading times are now acceptable.

  • I think, you cannot store large images using `precacheImage`. It's mentioned in the document (https://api.flutter.dev/flutter/widgets/precacheImage.html). try this plugin https://pub.dev/packages/cached_network_image – BIS Tech Mar 31 '22 at 03:30
  • @BISTech precacheImage.maximumSize is 100 MB so I don't think that was the problem. I kept the same precaching technique I originally used and got the images down to 400 kb each. Load times are now acceptable. Thank you for commenting. I will be updating my question. – Leonardo Hysesani Mar 31 '22 at 16:45

0 Answers0