From a00d250f87ee6fc83004390a2f4cc7a26dd7cd5a Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Mon, 9 Jan 2023 01:12:49 -0500 Subject: [PATCH] fix: check empty bytes before decoding (#868) --- lib/components/image/resilient_network_image.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/components/image/resilient_network_image.dart b/lib/components/image/resilient_network_image.dart index 0302bf88d..ae8fd8e62 100644 --- a/lib/components/image/resilient_network_image.dart +++ b/lib/components/image/resilient_network_image.dart @@ -146,8 +146,11 @@ class ResilientNetworkImage extends ImageProvider { if (await cacheFile.exists() && await etagFile.exists()) { try { final bytes = await cacheFile.readAsBytes(); - decodedCache = await decode(await ImmutableBuffer.fromUint8List(bytes)); - etagValue = await etagFile.readAsString(); + if (bytes.isNotEmpty) { + decodedCache = + await decode(await ImmutableBuffer.fromUint8List(bytes)); + etagValue = await etagFile.readAsString(); + } } catch (e) { FirebaseCrashlytics.instance.recordError(e, StackTrace.current); }