For image_picker MainActivity destruction I wanted to use other plugin to pick image. And I found wechat_camera_picker
as an alternative. But there was a problem while capturing the image. The captured image saved on Local Storage after selecting the image. Here is my code.
Future<File> getImageByCamera(BuildContext context) async {
try{
final AssetEntity result = await CameraPicker.pickFromCamera(
context,
pickerConfig: CameraPickerConfig(
shouldDeletePreviewFile: true,
enableRecording: false,
textDelegate: EnglishCameraPickerTextDelegate(),
),
);
if(result != null){
File pickedFile = await result.file;
pickedFile = await compressFile(pickedFile);
return pickedFile;
}else{
return null;
}
}catch(error){
print(error);
return null;
}
}
Does anyone have any solution of this problem?
CodePudding user response:
you can use the below function to delete the locally stored file.
Future<int> deleteFile(File pickedFile) async {
try {
await file.delete();
} catch (e) {
return 0;
}
}