final File file = File(); // 你的File对象
final Uint8List byteData = await file.readAsBytes(); // 转为Uint8List
final AssetEntity imageEntity = await PhotoManager.editor.saveImage(byteData); // 存入手机并生成AssetEntity
final AssetEntity videoEntity = await PhotoManager.editor.saveVideo(byteData); // 存入手机并生成AssetEntity
//对AssetEntity对象的操作...
//如果不想保留文件,可以在操作完成后进行删除:
PhotoManager.editor.deleteWithIds([entity.id]);
flutter File转换为AssetEntity
于 2024-03-19 10:15:50 首次发布
本文介绍了如何在Flutter中使用PhotoManager库将File对象转换为Uint8List,保存图片和视频为AssetEntity,以及如何在操作后删除这些AssetEntity。
2419

被折叠的 条评论
为什么被折叠?



