toImage method

Future<Image> toImage()

Return a new Image based on the src of the Sprite.

Note: This is a heavy async operation and should not be called inside the game loop.

Implementation

Future<Image> toImage() async {
  final composition = ImageComposition()
    ..add(image, Vector2.zero(), source: src);
  return composition.compose();
}