init method

Future<void> init()

Initializes the shape painter by loading the bitmap pattern if specified.

Implementation

Future<void> init() async {
  if (renderinstruction.bitmapSrc != null) {
    try {
      SymbolImage? symbolImage = await SymbolCacheMgr().getOrCreateSymbol(
        renderinstruction.bitmapSrc!,
        renderinstruction.getBitmapWidth(),
        renderinstruction.getBitmapHeight(),
      );
      if (symbolImage != null) {
        if (renderinstruction.isStrokeTransparent()) {
          // for bitmaps set the stroke color so that the bitmap is drawn
          stroke!.setColor(Colors.black);
        }
        stroke!.setBitmapShader(symbolImage);
        //symbolImage.dispose();
      }
    } catch (error) {
      _log.warning("Error loading bitmap ${renderinstruction.bitmapSrc}", error);
    }
  }
}