From 2075816df65153851539632660ec577d9c2d7ba0 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Wed, 10 Aug 2016 12:37:09 -0700 Subject: [PATCH] Decide whether to compress files in the FLX based on filename extensions (#5317) Previously the FLX builder compressed assets only if they were not dynamically generated. This meant that the license file was not compressed. --- packages/flutter_tools/lib/src/zip.dart | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/flutter_tools/lib/src/zip.dart b/packages/flutter_tools/lib/src/zip.dart index 9231aedbf5..158efbc1e6 100644 --- a/packages/flutter_tools/lib/src/zip.dart +++ b/packages/flutter_tools/lib/src/zip.dart @@ -88,15 +88,23 @@ class _ZipToolBuilder extends ZipBuilder { } } + static const List _kNoCompressFileExtensions = const ['.png', '.jpg']; + + bool isAssetCompressed(AssetBundleEntry entry) { + return !_kNoCompressFileExtensions.any( + (String extension) => entry.archivePath.endsWith(extension) + ); + } + Iterable _getCompressedNames() { return entries - .where((AssetBundleEntry entry) => !entry.isStringEntry) + .where(isAssetCompressed) .map((AssetBundleEntry entry) => entry.archivePath); } Iterable _getStoredNames() { return entries - .where((AssetBundleEntry entry) => entry.isStringEntry) + .where((AssetBundleEntry entry) => !isAssetCompressed(entry)) .map((AssetBundleEntry entry) => entry.archivePath); } }