diff --git a/lib/core/cache/image_cache.dart b/lib/core/cache/image_cache.dart index 472732f94..803048f9a 100644 --- a/lib/core/cache/image_cache.dart +++ b/lib/core/cache/image_cache.dart @@ -1,16 +1,16 @@ -import 'dart:typed_data'; +import 'dart:io'; import 'package:photos/core/cache/lru_map.dart'; import 'package:photos/models/photo.dart'; class ImageLruCache { - static LRUMap _map = LRUMap(500); + static LRUMap _map = LRUMap(500); - static Uint8List get(Photo photo) { + static File get(Photo photo) { return _map.get(photo.generatedId); } - static void put(Photo photo, Uint8List imageData) { + static void put(Photo photo, File imageData) { _map.put(photo.generatedId, imageData); } } diff --git a/lib/ui/zoomable_image.dart b/lib/ui/zoomable_image.dart index f58e2db95..0edaa4ab5 100644 --- a/lib/ui/zoomable_image.dart +++ b/lib/ui/zoomable_image.dart @@ -1,4 +1,4 @@ -import 'dart:typed_data'; +import 'dart:io'; import 'package:flutter/widgets.dart'; import 'package:photos/core/cache/image_cache.dart'; import 'package:photos/core/cache/thumbnail_cache.dart'; @@ -72,11 +72,11 @@ class _ZoomableImageState extends State { if (cachedImage != null) { _onFinalImageLoaded(cachedImage, context); } else { - widget.photo.getBytes().then((bytes) { + widget.photo.getAsset().file.then((file) { if (mounted) { setState(() { - _onFinalImageLoaded(bytes, context); - ImageLruCache.put(widget.photo, bytes); + _onFinalImageLoaded(file, context); + ImageLruCache.put(widget.photo, file); }); } }); @@ -108,8 +108,8 @@ class _ZoomableImageState extends State { _loadedLargeThumbnail = true; } - void _onFinalImageLoaded(Uint8List bytes, BuildContext context) { - final imageProvider = Image.memory(bytes).image; + void _onFinalImageLoaded(File file, BuildContext context) { + final imageProvider = Image.file(file).image; precacheImage(imageProvider, context).then((value) { if (mounted) { setState(() {