所以目前我的任务是将一个base64列表转换为flutter web中的图像。我尝试过使用Flutter Web的归档包,我写了这样的代码:
...
import 'package:archive/archive.dart';
...
var encoder = ZipEncoder();
var archive = Archive();
for (String imgB64 in ListOfB64) {
Uint8List imageByte = base64.decode(imgB64);
ArchiveFile archiveFiles =
ArchiveFile.stream("filename.png",imageByte.lengthInBytes,imageByte as InputStreamBase);
archive.addFile(archiveFiles);
}
var outputStream = OutputStream(byteOrder: LITTLE_ENDIAN,);
var bytes = encoder.encode(archive,level: Deflate.BEST_COMPRESSION,output: outputStream);
download("test.zip",bytes) //download the recently created .zip file
字符串
但我总是得到Uncaught (in promise) Error: Expected a value of type 'InputStreamBase', but got one of type 'NativeUint8List'
的错误,但似乎我找不到一种方法将Uint8List转换为InputStreamBase。
1条答案
按热度按时间2fjabf4q1#
嘿我想好了如果你还需要的话。我也想这么做。只需将字节文件 Package 在这个'InputStream()'中,即InputStream(bytesHere).