getImageData method
获取图片数据
Implementation
Future<ByteData?> getImageData() async {
try {
final RenderRepaintBoundary boundary = painterKey.currentContext!
.findRenderObject()! as RenderRepaintBoundary;
final ui.Image image = await boundary.toImage(
pixelRatio: View.of(painterKey.currentContext!).devicePixelRatio);
return await image.toByteData(format: ui.ImageByteFormat.png);
} catch (e) {
debugPrint('获取图片数据出错:$e');
return null;
}
}