saveBytes2Album static method
Future<SaveResult?>
saveBytes2Album(
- Uint8List bytes, {
- ImageByteFormat format = ImageByteFormat.png,
- String? fileName,
- int quality = 80,
将图片保存到相册,返回路径
Implementation
static Future<SaveResult?> saveBytes2Album(Uint8List bytes, {ImageByteFormat format = ImageByteFormat.png,
String? fileName, int quality = 80}) async {
if(!GetPlatform.isMobile){
return SaveResult(path: await FileSaver.instance.saveFile(name: fileName?? "${DateUtil.nowMs()}", bytes: bytes,
ext: "png", mimeType: MimeType.png));
}else{
var permResult = await _requestPermission();
if(permResult.isGranted || permResult.isLimited){
final result = await ImageGallerySaver.saveImage(bytes,
name: fileName,
quality: quality,
isReturnImagePathOfIOS: true);
return SaveResult(path: result["filePath"]);
}
return SaveResult(permissionDenied: true);
}
}