在堆栈的某个地方,我找到了一个有关如何共享图像通过共享软件包(https://pub.dartlang.org/packages/share#-readme-tab-)的答案,有人说将Bytes转换为base64编码,然后像这样共享此字符串:
ByteData byteData = await image.toByteData(format: ui.ImageByteFormat.png);
Uint8List pngBytes = byteData.buffer.asUint8List();
String bs64 = base64Encode(pngBytes);
await Share.share(bs64).then((response){
Future.delayed(const Duration(milliseconds: 2000), () {
setState(() {
loadingShare = false;
loadingShareIndex = -1;
});
});
});`
我期望显示一张图片,但只显示要分享的长字符串...