Below is an updated fix that aligns with the current version of the vector_graphics
source code you provided. The original issue involved a runtime crash (_TypeError
) occurring when attempting to draw <image>
elements. With the newer code that uses ImmutableBuffer
and ImageDescriptor
, the decoding pipeline is already correct. The likely cause of the crash is that onDrawImage
may be invoked before the image has finished decoding or if the image failed to decode, resulting in a null
lookup from the _images
map.
To address this safely, we should:
- Check if the image is available in
_images
before drawing. - If the image is not yet ready or failed to load, handle the scenario gracefully (e.g., skip drawing or report an error).
Updated onDrawImage
method: