我使用ui.PictureRecorder()但它给出了空白输出
var pictureRecorder = ui.PictureRecorder();
Canvas canvas = Canvas(pictureRecorder);
canvas.drawImage(image, Offset.zero, Paint());
final img = pictureRecorder.endRecording();
Future<ui.Image> _img = img.toImage(300, 300);
print('_img:${_img.toString()}');
canvas.drawImage(_img, Offset(100, 100), Paint());
当我使用它时,“参数类型'Future'不能分配给参数类型'Image'。”发生此警告,输出为空白
最佳答案
对于错误消息“将来”无法分配给参数类型“图像”,请从
Future<ui.Image> _img = img.toImage(300, 300);
至
var _img = await img.toImage(300, 300);
而且这行不起作用
canvas.drawImage(_img, Offset(100, 100), Paint());
因为pictureRecorder adlready endRecording,所以有错误
Object has been disposed.