From 09a1d2821c76737a8e6e018450603e5055777e51 Mon Sep 17 00:00:00 2001 From: nyne Date: Sun, 19 Oct 2025 21:49:25 +0800 Subject: [PATCH] Enhance onResponse handling in ImageDownloader to support Future and validate result type --- lib/network/images.dart | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/network/images.dart b/lib/network/images.dart index b361813..8953c61 100644 --- a/lib/network/images.dart +++ b/lib/network/images.dart @@ -181,7 +181,15 @@ abstract class ImageDownloader { } if (configs['onResponse'] is JSInvokable) { - buffer = (configs['onResponse'] as JSInvokable)([Uint8List.fromList(buffer)]); + dynamic result = (configs['onResponse'] as JSInvokable)([Uint8List.fromList(buffer)]); + if (result is Future) { + result = await result; + } + if (result is List) { + buffer = result; + } else { + throw "Error: Invalid onResponse result."; + } (configs['onResponse'] as JSInvokable).free(); }