手机截图功能,第一个写pixelRatio比例为1,发现截图很模糊,仔细查阅,才发现需要获取当前像素比
try {
RenderRepaintBoundary boundary =
rootWidgetKey.currentContext.findRenderObject();
var dpr = window.devicePixelRatio;
var image = await boundary.toImage(pixelRatio: dpr);
ByteData byteData = await image.toByteData(format: ImageByteFormat.png);
Uint8List pngBytes = byteData.buffer.asUint8List();
final result = await ImageGallerySaver.saveImage(pngBytes);
BotToast.showText(
text: ObjectUtil.isEmpty(result) ? '保存失败,请稍后再试' : '保存相册成功');
} catch (e) {
print(e);
}
更多详解:
喜欢可以加Q群号:913934649,点赞,评论;
简书: https://www.jianshu.com/u/88db5f15770d
csdn:https://me.csdn.net/beyondforme
掘金:https://juejin.im/user/5e09a9e86fb9a016271294a7