From 3fe0ef8454fd709f7f8bdb972ba3ddb9bdd3a51a Mon Sep 17 00:00:00 2001 From: Henry-Hiles Date: Thu, 19 Nov 2026 10:15:28 -0500 Subject: [PATCH] fix avif decoding --- lib/helpers/mxc_image.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/helpers/mxc_image.dart b/lib/helpers/mxc_image.dart index 15c4328..d82d485 100644 --- a/lib/helpers/mxc_image.dart +++ b/lib/helpers/mxc_image.dart @@ -1,6 +1,7 @@ import "dart:async"; import "dart:io"; import "dart:isolate"; +import "dart:typed_data"; import "dart:ui" as ui; import "package:avif_native/avif_native.dart"; @@ -29,7 +30,7 @@ class MxcImage(final WidgetRef ref, final DownloadMediaRequest request) // Flutter can't decode AVIF on Linux/Windows (or older Android/iOS), so we do it ourselves if (String.fromCharCodes(bytes.skip(4).take(8)) case "ftypavif" || "ftypavis") { - return AvifCodec(await Isolate.run(() => decodeAvif(bytes))); + return AvifCodec(await _decodeAvifInIsolate(bytes)); } return await decode(await .fromUint8List(bytes)); @@ -39,6 +40,9 @@ class MxcImage(final WidgetRef ref, final DownloadMediaRequest request) } } + static Future _decodeAvifInIsolate(Uint8List bytes) => + Isolate.run(() => decodeAvif(bytes)); + @override bool operator ==(Object other) => other is MxcImage && other.request == request;