Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reintroduce caching with a limit #745

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/shared/image_preview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ class _ImagePreviewState extends State<ImagePreview> {
width: widget.width ?? MediaQuery.of(context).size.width - 24,
fit: BoxFit.cover,
cache: true,
clearMemoryCacheWhenDispose: true,
clearMemoryCacheWhenDispose: false,
cacheMaxAge: const Duration(minutes: 1),
cacheWidth: ((MediaQuery.of(context).size.width - 24) * View.of(context).devicePixelRatio.ceil()).toInt(),
loadStateChanged: (state) {
if (state.extendedImageLoadState == LoadState.loading) {
Expand Down
3 changes: 2 additions & 1 deletion lib/shared/image_viewer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ class _ImageViewerState extends State<ImageViewer> with TickerProviderStateMixin
mode: ExtendedImageMode.gesture,
extendedImageGestureKey: gestureKey,
cache: true,
clearMemoryCacheWhenDispose: true,
clearMemoryCacheWhenDispose: false,
cacheMaxAge: const Duration(minutes: 1),
initGestureConfigHandler: (ExtendedImageState state) {
return GestureConfig(
minScale: 0.8,
Expand Down
3 changes: 2 additions & 1 deletion lib/shared/media_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ class _MediaViewState extends State<MediaView> with SingleTickerProviderStateMix
width: width,
fit: widget.viewMode == ViewMode.compact ? BoxFit.cover : BoxFit.fitWidth,
cache: true,
clearMemoryCacheWhenDispose: true,
clearMemoryCacheWhenDispose: false,
cacheMaxAge: const Duration(minutes: 1),
cacheWidth: widget.viewMode == ViewMode.compact
? (75 * View.of(context).devicePixelRatio.ceil())
: ((MediaQuery.of(context).size.width - (widget.edgeToEdgeImages ? 0 : 24)) * View.of(context).devicePixelRatio.ceil()).toInt(),
Expand Down
3 changes: 2 additions & 1 deletion lib/shared/preview_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ class _PreviewImageState extends State<PreviewImage> with SingleTickerProviderSt
width: width,
fit: widget.viewMode == ViewMode.compact ? BoxFit.cover : BoxFit.fitWidth,
cache: true,
clearMemoryCacheWhenDispose: true,
clearMemoryCacheWhenDispose: false,
cacheMaxAge: const Duration(minutes: 1),
cacheWidth: widget.viewMode == ViewMode.compact ? (75 * View.of(context).devicePixelRatio.ceil()) : ((MediaQuery.of(context).size.width - 24) * View.of(context).devicePixelRatio.ceil()).toInt(),
loadStateChanged: (ExtendedImageState state) {
switch (state.extendedImageLoadState) {
Expand Down
Loading