Optimizing image loading speed in Flutter

Tram Ho

A good mobile application requires fast data loading, optimal performance. That is a must-have condition if you want users to have the best experience ..

.. In this article we also go into learn the Progressive Image Loading technique that most of the web today use.

Progressive Image Loading techniques

To see how images are loaded using progressive technique see the video below

1. First, the app will load an image from assets to display.
2. Then will load 1 thumbnail version (thumbnail) of the image, this image has a very small size of about 1-10kb. so this image loads very quickly
3. Once the thumbnail has loaded, the original image will be loaded for display

How to do it on the flutter

1. Add package

Go to the link https://pub.dev/packages/progressive_image/instal . to add the latest package
2. Add placeholder image to assets.
Visit https://bit.ly/34Kxhbo to load placeholder images and add them to the project as shown below. If you don’t have an assets folder, create a new one.

After adding an image to assets, let’s go to the file pubspec.yaml to add a path to access the assets. If you do not know about assets in flutter, please refer to https://flutter.dev/docs/development/ui/assets-and-images .

Run the command pub get to update changes

flutter pub get

3. Start coding

Quite simple is not it

Source code


Share the news now

Source : Viblo