random method

Request<List<Photo>> random({
  1. String? query,
  2. String? username,
  3. bool? featured,
  4. Iterable<String>? collections,
  5. PhotoOrientation? orientation,
  6. int count = 1,
  7. ContentFilter? contentFilter,
})

Get a random photo

Retrieve a one or more random photos, given optional filters.

See: Unsplash docs

Implementation

Request<List<Photo>> random({
  String? query,
  String? username,
  bool? featured,
  Iterable<String>? collections,
  PhotoOrientation? orientation,
  int count = 1,
  ContentFilter? contentFilter,
}) {
  assert(count >= 0 && count <= client.settings.maxPageSize);

  final params = queryParams({
    'query': query,
    'username': username,
    'featured': featured,
    'collections': collections?.join(','),
    'orientation': orientation?.let(enumName),
    'count': count,
    'content_filter': contentFilter?.let(enumName),
  });

  final url = baseUrl.resolve('random').replace(queryParameters: params);

  return Request(
    client: client,
    httpRequest: http.Request('GET', url),
    isPublicAction: true,
    bodyDeserializer: _deserializePhotos,
  );
}