From 4129349c7005120adfa617f46bd18ac2b6bb6861 Mon Sep 17 00:00:00 2001 From: nyne Date: Wed, 3 Sep 2025 22:09:07 +0800 Subject: [PATCH] Improve js api `onResponse` --- lib/network/images.dart | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/network/images.dart b/lib/network/images.dart index 8255e97..b361813 100644 --- a/lib/network/images.dart +++ b/lib/network/images.dart @@ -181,12 +181,17 @@ abstract class ImageDownloader { } if (configs['onResponse'] is JSInvokable) { - buffer = (configs['onResponse'] as JSInvokable)([buffer]); + buffer = (configs['onResponse'] as JSInvokable)([Uint8List.fromList(buffer)]); (configs['onResponse'] as JSInvokable).free(); } - var data = Uint8List.fromList(buffer); - buffer.clear(); + Uint8List data; + if (buffer is Uint8List) { + data = buffer; + } else { + data = Uint8List.fromList(buffer); + buffer.clear(); + } if (configs['modifyImage'] != null) { var newData = await modifyImageWithScript(