package:flutter/src/rendering/proxy_box.dart': 失败的断言: line 2813 pos 12: '!debugNeedsPaint': 不是真的。
我正在尝试在颤振中截取屏幕截图,但出现异常。我访问了许多链接,但没有任何效果。
Future<Uint8List> _capturePng() async {
try {
print('inside');
RenderRepaintBoundary boundary = _globalKey.currentContext.findRenderObject();
ui.Image image = await boundary.toImage(pixelRatio: 3.0);
ByteData byteData = await image.toByteData(format: ui.ImageByteFormat.png);
var pngBytes = byteData.buffer.asUint8List();
var bs64 = base64Encode(pngBytes);
print(pngBytes);
print(bs64);
setState(() {});
return pngBytes;
} catch (e) {
print(e);
}
}
Run Code Online (Sandbox Code Playgroud) flutter ×1