mirror of
https://github.com/venera-app/venera.git
synced 2025-12-15 22:51:15 +00:00
Enhance onResponse handling in ImageDownloader to support Future and validate result type
This commit is contained in:
@@ -181,7 +181,15 @@ abstract class ImageDownloader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (configs['onResponse'] is JSInvokable) {
|
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();
|
(configs['onResponse'] as JSInvokable).free();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user