I have a binary file I need to read its contents using retrofit for my flutter application.
I want to know if this could be possible or not.
if yes, any links, please?
Otherwise, I need some recommendations.
Thanks in advance for your help
I have a binary file I need to read its contents using retrofit for my flutter application.
I want to know if this could be possible or not.
if yes, any links, please?
Otherwise, I need some recommendations.
Thanks in advance for your help
2
Answers
First of all, you have to specify your
retrofit
client and specify your API inside and specifyReturnType.bytes
byDioResponseType
annotationI’ll make a simple example for downloading the image from the https://www.phoca.cz web site and in the same way you can download any type of files
Generate a code by
Initialise a client
And you can obtain the image through
Image.memory
The answer given by powerman23rus works perfectly with retrofit, but if you are looking for a package that requires less code, u can try the http package (https://pub.dev/packages/http) which doesn’t require tags or generated files. You can receive an image like this:
Once obtained, you can use this widget to render the image: