getThumbnail method

Uri getThumbnail(
  1. Client matrix, {
  2. num? width,
  3. num? height,
  4. ThumbnailMethod? method = ThumbnailMethod.crop,
  5. bool? animated = false,
})

Returns a scaled thumbnail link to this content with the given width and height. method can be ThumbnailMethod.crop or ThumbnailMethod.scale and defaults to ThumbnailMethod.scale. If animated (default false) is set to true, an animated thumbnail is requested as per MSC2705. Thumbnails only animate if the media repository supports that.

Implementation

Uri getThumbnail(Client matrix,
    {num? width,
    num? height,
    ThumbnailMethod? method = ThumbnailMethod.crop,
    bool? animated = false}) {
  if (!isScheme('mxc')) return this;
  final homeserver = matrix.homeserver;
  if (homeserver == null) {
    return Uri();
  }
  return Uri(
    scheme: homeserver.scheme,
    host: homeserver.host,
    path: '/_matrix/media/v3/thumbnail/$host${hasPort ? ':$port' : ''}$path',
    port: homeserver.port,
    queryParameters: {
      if (width != null) 'width': width.round().toString(),
      if (height != null) 'height': height.round().toString(),
      if (method != null) 'method': method.toString().split('.').last,
      if (animated != null) 'animated': animated.toString(),
    },
  );
}