loadImage method

Future<void> loadImage({
  1. bool clearImageData = true,
  2. Images? images,
})

Loads the atlas image into memory so it can be used, this method is used internally by loadAsset, prefer that method unless there is a very specific use case for it.

clearImageData Can be set to false to avoid clearing the stored information about the image on this object, this is true by default, its use is intended to enable serializing this object images The images cache to be used, falls back to Flame.images when omitted.

Implementation

Future<void> loadImage({bool clearImageData = true, Images? images}) async {
  if (imageData == null) {
    throw 'Attempting on calling load on an already loaded Image';
  }
  final imagesCache = images ?? Flame.images;
  _image = await imagesCache.fromBase64(id, imageData!);

  // Clear memory
  if (clearImageData) {
    imageData = null;
  }
}