Skip to content

Commit

Permalink
🐛 Fix onEntitySaving not returned after called (#223)
Browse files Browse the repository at this point in the history
Fixes #222

(cherry picked from commit 9224ad0)
  • Loading branch information
AlexV525 committed Nov 17, 2023
1 parent 2203168 commit 1472184
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/src/states/camera_picker_viewer_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ class CameraPickerViewerState extends State<CameraPickerViewer> {
setState(() {
isSavingEntity = true;
});
final CameraPickerViewType viewType = widget.viewType;

// Handle the explicitly entity saving method.
if (widget.pickerConfig.onEntitySaving != null) {
try {
await widget.pickerConfig.onEntitySaving!(
Expand All @@ -145,12 +146,14 @@ class CameraPickerViewerState extends State<CameraPickerViewer> {
isSavingEntity = false;
});
}
return;
}

AssetEntity? entity;
try {
final PermissionState ps = await PhotoManager.requestPermissionExtend();
if (ps == PermissionState.authorized || ps == PermissionState.limited) {
switch (viewType) {
switch (widget.viewType) {
case CameraPickerViewType.image:
final String filePath = previewFile.path;
entity = await PhotoManager.editor.saveImageWithPath(
Expand All @@ -167,7 +170,10 @@ class CameraPickerViewerState extends State<CameraPickerViewer> {
}
if (widget.pickerConfig.shouldDeletePreviewFile &&
previewFile.existsSync()) {
previewFile.delete();
previewFile.delete().catchError((e, s) {
handleErrorWithHandler(e, s, onError);
return previewFile;
});
}
return;
}
Expand Down

0 comments on commit 1472184

Please sign in to comment.