在此处输入图像描述我创建了用于截屏并将其附加到空小部件的函数
代码
Future<Function> TakeScreenShot(BuildContext context) async {
RenderRepaintBoundary boundary =
previewContainer.currentContext.findRenderObject();
print(boundary.debugNeedsPaint);
//assert(!boundary.debugNeedsPaint);
ui.Image image = await boundary.toImage();
ByteData byteData = await image.toByteData(format: ui.ImageByteFormat.png);
Uint8List pngBytes = byteData.buffer.asUint8List();
setState(() {
takenScreenShot.add(Image.memory(
pngBytes,
width: 200.0,
height: 150.0,
));
});
}
Run Code Online (Sandbox Code Playgroud)
但它不是从第一次运行,编译器显示
'!debugNeedsPaint': 不是真的。
但在第一次点击后它就起作用了。如何将 (debugNeedsPaint) 更改为 false?
| 归档时间: |
|
| 查看次数: |
672 次 |
| 最近记录: |