gpt4 book ai didi

android - ui.PictureRecorder() 在 flutter 中给出空白输出?

转载 作者:行者123 更新时间:2023-11-29 05:25:56 25 4
gpt4 key购买 nike

我使用 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());

when i use this then "The argument type 'Future' can't be assigned to the parameter type 'Image'." this warning occurs and output is blank

最佳答案

对于错误消息“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结束录制,所以出现错误

Object has been disposed.

关于android - ui.PictureRecorder() 在 flutter 中给出空白输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58169735/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com