fetchOrGenerate method

Future<Image> fetchOrGenerate(
  1. String name,
  2. Future<Image> imageGenerator()
)

If the image with name exists in the cache that is returned, otherwise the image generated by imageGenerator is returned.

If the imageGenerator is used, the resulting Image is stored with name in the cache.

Implementation

Future<Image> fetchOrGenerate(
  String name,
  Future<Image> Function() imageGenerator,
) {
  return (_assets[name] ??= _ImageAsset.future(imageGenerator()))
      .retrieveAsync();
}