So at the moment of this post, I tried using DIO library, but currently all different methods they provide did not work for me.
Following a similar question someone made for flutter itself(not mobile), one of the answers provided by: @Mehul Prajapati here: https://stackoverflow.com/a/64604174/8377232.
I did the the following:
Instead of Dio library, use http library like this:
Future<void> _uploadImage(Uint8List binaryImage) async {
Response response = await http.post(
Uri.parse('<your url here> '),
headers: {
'Content-Type': "text/plain",
'Accept': "*/*",
'Content-Length': binaryImage.toString(),
'Connection': 'keep-alive',
},
body: binaryImage,
);
}
And in order to get the binaryImage itself(which is an array of int8 numbers) I did the following:
This is the value I am sending to the method above, you might also need to modify your content-type according to your server API's need: to something like "image/jpeg" or whatever needed.
Thanks.