‘I’m utilizing the saver_gallery package deal of Flutter to avoid wasting photographs into my telephone gallery on each IOS and android. I’m utilizing the picture picker package deal to take the picture utilizing digicam. Once I save the picture in my app, I can see it’s there within the gallery on an android telephone however it’s failing on an IOS machine. Additionally if I reopen the app on the IOS machine neither can I see that picture on my app as nicely.’
Future checkAndRequestPermissions({required bool skipIfExists}) async
{
if (!Platform.isAndroid && !Platform.isIOS)
{
return false; // Solely Android and iOS platforms are supported
}
if (Platform.isAndroid) {
ultimate deviceInfo = await DeviceInfoPlugin().androidInfo;
ultimate sdkInt = deviceInfo.model.sdkInt;
if (skipIfExists) {
// Learn permission is required to examine if the file already exists
return sdkInt >= 33
? await Permission.pictures.request().isGranted
: await Permission.storage.request().isGranted;
} else {
// No learn permission required for Android SDK 29 and above
return sdkInt >= 29 ? true : await Permission.storage.request().isGranted;
}
} else if (Platform.isIOS) {
// iOS permission for saving photographs to the gallery
return skipIfExists
? await Permission.pictures.request().isGranted
: await Permission.photosAddOnly.request().isGranted;
}
return false; // Unsupported platforms
}
Future saveImageToGallery(File imageFile, String imageName, {bool skipIfExists = false}) async{
ultimate hasPermissions = await checkAndRequestPermissions(skipIfExists: skipIfExists);
if(!hasPermissions){
print("Permission Denied");
return;
}
ultimate savedImage = await SaverGallery.saveFile(
filePath: imageFile.path,
fileName: "$imageName.jpg",
androidRelativePath: "Photos/my_app",
skipIfExists: skipIfExists);
if(savedImage.isSuccess == true) {
print(imageFile.path);
} else{
print("Failed");
}
}
/* That is my operate to take a picture utilizing camersa*/
Future addImageFromCamera() async {
ultimate pickedImage = await imagePick.pickImage(supply: ImageSource.digicam);
return pickedImage != null ? File(pickedImage.path) : null;
}
‘That is my code for a similar. I’m utilizing the very same code they’ve used within the pub.dev web page of the saver_gallery package deal, solely I’m utilizing a file as an alternative of picture bytes. I consider the picture is saved briefly and it’s deleted later which is why I cant see it within the app as nicely. If anybody can please assist me with this it could be of nice assist. Thanks upfront.’