I have a cloud function that generates a JavaScript Buffer object, which looks something like this:
functions
.region("europe-west2")
.runWith({ timeoutSeconds: 20, memory: "128MB", })
.https
.onCall(async (data, context) => {
const buffer = await sharp(imagePath).toBuffer();
return buffer;
});
In my code repository, I interact with this cloud function in the following way:
Future<Uint8List> resizeImage({required String fileName}) async {
try {
final result = await firebaseFunctions
.httpsCallable('resizeImage')
.call<dynamic>({'fileName': fileName});
//printing result.data returns an IdentityMap<String, dynamic>.
} on FirebaseFunctionsException catch (e) {
//handle error
}
}
Whenever I print result.data.runtimeType, it shows as a map object with values like this :
{12: 239, 2938: 293}
How can I convert this map into a UInt8List?