photos method
Request<SearchResults<Photo> >
photos(
- String query, {
- int? page,
- int? perPage,
- Iterable<
String> ? collections, - PhotoColor? color,
- PhotoOrientation? orientation,
- PhotoOrder? orderBy,
- ContentFilter? contentFilter,
- String? lang,
Search photos
Get a single page of photo results for a query.
The photo objects returned here are abbreviated. For full details use Photos.get.
See: Unsplash docs
Implementation
Request<SearchResults<Photo>> photos(
String query, {
int? page,
int? perPage,
Iterable<String>? collections,
PhotoColor? color,
PhotoOrientation? orientation,
PhotoOrder? orderBy,
ContentFilter? contentFilter,
String? lang,
}) {
assert(page == null || page >= 0);
assert(perPage == null ||
perPage >= 0 && perPage <= client.settings.maxPageSize);
final params = queryParams({
'query': query,
'page': page,
'per_page': perPage,
'collections': collections?.join(','),
'orientation': orientation?.let(enumName),
'order_by': orderBy?.let(enumName),
'color': color?.let(enumName),
'content_filter': contentFilter?.let(enumName),
'lang': lang,
});
final url = baseUrl.resolve('photos').replace(queryParameters: params);
return Request(
client: client,
httpRequest: http.Request('GET', url),
isPublicAction: true,
bodyDeserializer: (dynamic json) => SearchResults.fromJson(
json as Map<String, dynamic>, (json) => Photo.fromJson(json)),
);
}