Skip to content

Commit

Permalink
⚡️ Evict the captured image cache once returned from the viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 committed Apr 28, 2024
1 parent 8a5ff85 commit b92f9db
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/src/states/camera_picker_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1070,15 +1070,24 @@ class CameraPickerState extends State<CameraPicker>
required XFile file,
required CameraPickerViewType viewType,
}) async {
final FileImage? image;
if (viewType == CameraPickerViewType.image) {
image = FileImage(File(file.path));
await precacheImage(FileImage(File(file.path)), context);
} else {
image = null;
}
return CameraPickerViewer.pushToViewer(
final result = await CameraPickerViewer.pushToViewer(
context,
pickerConfig: pickerConfig,
viewType: viewType,
previewXFile: file,
);
if (image != null) {
final evicted = PaintingBinding.instance.imageCache.evict(image);
realDebugPrint('Preview image cache evicted: $evicted');
}
return result;
}

////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit b92f9db

Please sign in to comment.