我正在开发一个 iOS/Android/Web 应用程序,在这里我使用 pdf 插件根据用户输入生成 PDF:https : //pub.dev/packages/pdf。在iOS和Android上,我可以访问文件系统,所以我可以先保存生成的pdf,然后用任何pdf显示插件打开它。
但是,对于 Flutter web,据我所知,无法访问任何类型的文件系统。我见过的所有 pdf 渲染插件都假设 pdf 文件要么存储在文件中,要么存储在网络上。我在看:
如何在flutter web上显示这个应用程序生成的pdf?有没有办法将 Uint8List 数据欺骗为文件,或者可能是另一种方法来解决这个问题?(我能想到的唯一解决方法是在生成文件后将文件上传到网络以显示它,但这似乎有点过分了。)
我开发了一个带有颤振的移动应用程序。我做对象检测使用“controller.startImageStream”这个方法返回CameraImage,我使用对象检测。我想保存这个图像文件。我试图将此文件转换为 List 和 jpg 文件以进行保存。但是 uint8list 无法转换为 List。这种结构是真的吗?如果您知道我的问题的不同解决方案,请与我分享。
这是我的视频流方法;
startVideoStreaming() {
if (cameras == null || cameras.length < 1) {
print('No camera is found');
} else {
controller = new CameraController(
cameras[0],
ResolutionPreset.medium,
);
if(!_busy){
controller.initialize().then((_) {
print("model yükleme bitmi? stream dinleme ba?l?yor ");
controller.startImageStream((CameraImage img){
print("img format: ${img.format} planes: ${img.planes}");
List<int> imageBytes = [];
img.planes.map((plane) {
imageBytes.addAll(plane.bytes.toList());
});
// call save image file method
saveImageFile(imageBytes).then((res) => {
print("save image file successfull filepath: $res")
}).catchError((err) => {
print("error on save …Run Code Online (Sandbox Code Playgroud) 在 android 10 和 11(SDK 编号 29 和 30)中,音乐封面(艺术品)格式与以前的版本不同,事实上,它们不能作为受支持的图像文件(例如 jpg 或 png)读取,它们是 uint8lists 和只有 Image.memory 小部件接受并显示它们。
现在,我的问题是我不想将它们作为内存图像读取,我需要 jpg 等文件。
找了很多!读了很多,发现只有 1 个,不起作用的解决方案!这就是将 unit8list 作为字节写入文件中,其路径以“.jpg”结尾。正如我所说,它不起作用。
有人可以帮忙吗?
提前致谢,<3。
final io.File image = File('directory/image.jpg').create();
image.writeAsBytesSync(uint8list);
Run Code Online (Sandbox Code Playgroud)
uint8list 样本:[255, 216, 255, 224, 0, 16, 74, 70, 73, 70, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 255, 226, 2, 40, 73, 67, 67, 95, 80, 82 ,...]
长度:数千
我在 flutter web 上将 Uint8List 图像转换为文件时遇到问题,因为 dart:io 在网络上不受支持,我需要将其作为文件才能将其上传到 FirebaseStorage,是否有任何解决方法?谢谢
我有一些 Uint8lists,我想将它们保存为 jpg 文件。我在网上搜索了很多,但一无所获!任何人都可以帮忙吗?
谢谢,
Uint8List我想在使用以下命令将图像上传到 firebase 存储之前找出图像的大小
StorageUploadTask uploadTask = reference.putData(uint8ListImage);
Run Code Online (Sandbox Code Playgroud)
其中uint8ListImage是Uint8List。有没有办法知道 的大小Uint8List?
我有一个Unit8List列表,它存储多个图像的数据。我想与其他活动共享该列表,以便其他活动可以使用该列表来显示图像。那么我如何使用SharedPreferences进行共享?或者有什么方法可以用来传递具有 Unit8List 对象的列表?
flutter ×7
uint8list ×7
dart ×5
flutter-web ×2
uint8array ×2
file ×1
image ×1
list ×1
pdf ×1
size ×1