异步功能未完成

时间:2020-01-28 13:44:45

标签: image flutter async-await save flutter-web

我正在尝试编写一个异步函数,用于将带有画布的图形保存到文件中。由于某种原因,该功能无法完成,这意味着未创建文件。我想知道该过程是否需要很长时间,因为抖动不会引发任何错误。

update

编辑:当前 void _saveImage() async { final recorder = new ui.PictureRecorder(); final canvas = new Canvas(recorder); MyPainter mypainter = new MyPainter( shapes: _shapes, lineColor: Colors.amber, width: 1.0 ); mypainter.paint(canvas,Size(1280, 720)); final picture = recorder.endRecording(); final img = await picture.toImage(1280, 720); final pngBytes = await img.toByteData(format: ImageByteFormat.png); //This line will not work File('/home/filename.png').writeAsBytesSync(await pngBytes.buffer.asInt8List()); } 不受Flutter网站的支持,请参见 https://github.com/flutter/flutter/issues/44908

0 个答案:

没有答案
相关问题