repaintBoundaryToImage function
Implementation
Future<img.Image?> repaintBoundaryToImage(
RenderRepaintBoundary renderer,
) async {
try {
final rawImage = await renderer.toImage(pixelRatio: 1);
final byteData =
await rawImage.toByteData(format: ui.ImageByteFormat.rawStraightRgba);
if (byteData == null) throw Exception('Null image byteData !');
final pngBytes = byteData.buffer;
return img.Image.fromBytes(
width: rawImage.width,
height: rawImage.height,
bytes: pngBytes,
order: img.ChannelOrder.rgba,
);
} catch (err, stackTrace) {
debugPrint('repaintBoundaryToImage... $err $stackTrace');
rethrow;
}
}