how do i convert a http response to a buffer? im using the http pub package https://pub.dev/packages/http and one of the endpoints of an api im using is returning an image file, i want to convert it to a buffer. in JS i'd just do
const result = await res.buffer();
but how do i do it in dart?
I tried a few different methods of the Response class but couldnt get my head around it
CodePudding user response:
Node describes Buffer as
The
Bufferclass is a subclass of JavaScript'sUint8Arrayclass
So it may safe assume that you can use the Response.bodyBytes (which is a dart Uint8List type) field as jamesdlin suggested.
