1
Future<void> _capturePng() async {
RenderRepaintBoundary boundary = globalKey.currentContext.findRenderObject();
ui.Image image = await boundary.toImage();
ByteData byteData = await image.toByteData(format: ui.ImageByteFormat.png);
Uint8List pngBytes = byteData.buffer.asUint8List();
setState(() {
  data = pngBytes;
});

}

如何将此 pngbytes 转换为文件以传递到数据形式?

FormData formData = new FormData.fromMap({
  "image": await MultipartFile.fromFile(image.path,filename: image.path.split("/").last),
  "signature": await MultipartFile.fromFile(here),
  "latitude": "${_currentPosition.latitude}, ${_currentPosition.longitude}",
});
4

0 回答 0