buildPhotoUrl method
Build photo url of a Place. This function will return the photo url with the necessary params to request the photo binary.
This function is ideal to be used directly with some ImageWidget
like Image.network
or CachedNetworkImage
so the image gets loaded directly from the url.
Note: take into account the photo will be obtained after a redirect.
Required params:
name
orplaceId
andphotoId
: If you opt to useplaceId
andphotoId
, set only the ids without the resource name.maxWidthPx
ormaxHeightPx
: You can specify one or both to set the the maximum desired height and width pixels of the image.
Documentation: https://developers.google.com/maps/documentation/places/web-service/place-photos#get-photo-ref
Implementation
String buildPhotoUrl({
/// This would be required only in case you initialized the [PlacesAPINew] with a [token] or [tokenCallback] instead of an [apiKey]. The reason is that the [apiKey] can be used as a query-param in the url.
String? apiKey,
/// Photo resource name: https://developers.google.com/maps/documentation/places/web-service/place-photos#photo-name
String? name,
/// Place identifier
String? placeId,
/// Photo identifier
String? photoId,
/// Maximum desired width of the image in pixels: https://developers.google.com/maps/documentation/places/web-service/place-photos#maxheightpx-and-maxwidthpx
int? maxWidthPx,
/// Maximum desired height of the image in pixels: https://developers.google.com/maps/documentation/places/web-service/place-photos#maxheightpx-and-maxwidthpx
int? maxHeightPx,
}) =>
_buildPhotoUrl(
apiKey: apiKey,
name: name,
placeId: placeId,
photoId: photoId,
maxWidthPx: maxWidthPx,
maxHeightPx: maxHeightPx,
skipHttpRedirect: false,
);