I'm about to start working on an Encyclopedia-like app, where I'd like my object Item to contain the main image as well as the list of other images for gallery purposes.

I've already done some research on how to store images in Flutter but I'm confused - some answered questions included:

  1. Assets - but it won't be easy to access them, filter, search and so on
  2. SQLite (Base64 encoding/decoding) - performance issues during loading and decoding/encoding list of image objects
  3. Keeping files on disk - longer loading times

so the question is - what is the best approach in this situation?

Any hints/tips much appreciated! :)


Solution 1: Günter Zöchbauer

  1. If you ship them statically with your application, assets will work well enough. Filter, search, and so on shouldn't be too hard.

  2. Yes, everything will be stored in a single file with some overhead and that will cause some performance issues.

  3. "Keeping files on disk" every way keeps the files on disks and the loading times are not avoidable. You might be able to load images in the background to have them in memory already when the user navigates to a view where they should be shown.

I would store them as asset if they are static (don't change after the app is shipped, or only with application updates)

You can use SQLite and maintain a table with meta-information about the images and a field with the image file name (and path if required) to benefit from query capabilities of a SQL database and best performance.

For more details more information is needed.


Solution 2: Shadeeka Nimesh

try like this method get more images

import 'dart:convert';

import 'dart:typed_data';

Uint8List bytesImage1;

bool bolWithImage1 = false;

try {

  bytesImage1 =

      base64Decode(base64StringFromSql);

  bolWithImage1 = true;

} catch (err) {}