getOrCreateSymbol method

  1. @override
Future<ResourceBitmap?> getOrCreateSymbol(
  1. String? src,
  2. int width,
  3. int height
)
override

loads and returns the desired symbol, optionally rescales it to the given width and height

Implementation

@override
Future<ResourceBitmap?> getOrCreateSymbol(
    String? src, int width, int height) async {
  if (src == null || src.length == 0) {
    // no image source defined
    return null;
  }
  String key = "$src-$width-$height";
  ResourceBitmap? resourceBitmap = _cache.get(key);
  if (resourceBitmap != null) {
    return resourceBitmap.clone();
  }

  resourceBitmap = await _createSymbol(src, width, height);
  _cache.set(key, resourceBitmap);
  return resourceBitmap.clone();
}