Enhance onResponse handling in ImageDownloader to support Future and validate result type

This commit is contained in:
2025-10-19 21:49:25 +08:00
committed by nyne
parent 7842b5a1ac
commit 09a1d2821c

View File

@@ -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<int>) {
buffer = result;
} else {
throw "Error: Invalid onResponse result.";
}
(configs['onResponse'] as JSInvokable).free();
}