Browse Source

Lower the quality of local thumbnails that are loaded

Vishnu Mohandas 4 years ago
parent
commit
8448b9baef
3 changed files with 11 additions and 2 deletions
  1. 1 0
      lib/core/constants.dart
  2. 5 1
      lib/ui/thumbnail_widget.dart
  3. 5 1
      lib/utils/file_util.dart

+ 1 - 0
lib/core/constants.dart

@@ -1,4 +1,5 @@
 const int THUMBNAIL_SMALL_SIZE = 256;
+const int THUMBNAIL_SMALL_SIZE_QUALITY = 80;
 const int THUMBNAIL_LARGE_SIZE = 512;
 const String SENTRY_DSN =
     "http://96780dc0b00f4c69a16c02e90d379996@3.211.17.56/2";

+ 5 - 1
lib/ui/thumbnail_widget.dart

@@ -90,7 +90,11 @@ class _ThumbnailWidgetState extends State<ThumbnailWidget> {
             return;
           }
           asset
-              .thumbDataWithSize(THUMBNAIL_SMALL_SIZE, THUMBNAIL_SMALL_SIZE)
+              .thumbDataWithSize(
+            THUMBNAIL_SMALL_SIZE,
+            THUMBNAIL_SMALL_SIZE,
+            quality: THUMBNAIL_SMALL_SIZE_QUALITY,
+          )
               .then((data) {
             if (data != null && mounted) {
               final imageProvider = Image.memory(data).image;

+ 5 - 1
lib/utils/file_util.dart

@@ -74,7 +74,11 @@ void preloadLocalFileThumbnail(File file) {
   }
   file.getAsset().then((asset) {
     asset
-        .thumbDataWithSize(THUMBNAIL_SMALL_SIZE, THUMBNAIL_SMALL_SIZE)
+        .thumbDataWithSize(
+      THUMBNAIL_SMALL_SIZE,
+      THUMBNAIL_SMALL_SIZE,
+      quality: THUMBNAIL_SMALL_SIZE_QUALITY,
+    )
         .then((data) {
       ThumbnailLruCache.put(file, THUMBNAIL_SMALL_SIZE, data);
     });