getImage method

Future<Uint8List> getImage({
  1. required String url,
  2. int? width,
  3. int? height,
})

Get Image from URL

Use this endpoint to fetch a remote image URL and crop it to any image size you want. This endpoint is very useful if you need to crop and display remote images in your app or in case you want to make sure a 3rd party image is properly served using a TLS protocol.

When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 400x400px.

Implementation

Future<Uint8List> getImage(
    {required String url, int? width, int? height}) async {
  const String path = '/avatars/image';

  final Map<String, dynamic> params = {
    'url': url,
    'width': width,
    'height': height,
    'project': client.config['project'],
  };

  final res = await client.call(HttpMethod.get,
      path: path, params: params, responseType: ResponseType.bytes);
  return res.data;
}