上一篇提到了保存本地的方法,但是保存后你会发现图片很模糊,这个时候需要在代码中加一行代码就会变清晰:
RenderRepaintBoundary boundary =
globalKey.currentContext.findRenderObject();
var dpr = window.devicePixelRatio;
ui.Image image = await boundary.toImage(pixelRatio: dpr);
ByteData byteData = await image.toByteData(format: ui.ImageByteFormat.png);
Uint8List picBytes = byteData.buffer.asUint8List();
final result = await ImageGallerySaver.saveImage(picBytes,
quality: 100, name: "dance_value_share");
var dpr = window.devicePixelRatio; ui.Image image = await boundary.toImage(pixelRatio: dpr);
这个代码加上后,图片会变得很清晰