buildPhotoUrl method

String buildPhotoUrl({
  1. required String photoReference,
  2. int? maxWidth,
  3. int? maxHeight,
})

Implementation

String buildPhotoUrl({
  required String photoReference,
  int? maxWidth,
  int? maxHeight,
}) {
  if (maxWidth == null && maxHeight == null) {
    throw ArgumentError("You must supply 'maxWidth' or 'maxHeight'");
  }

  final params = <String, String>{
    'photoreference': photoReference,
  };

  if (maxWidth != null) {
    params['maxwidth'] = maxWidth.toString();
  }

  if (maxHeight != null) {
    params['maxheight'] = maxHeight.toString();
  }

  if (apiKey != null) {
    params['key'] = apiKey!;
  }

  return url
      .replace(
        path: '${url.path}$_photoUrl',
        queryParameters: params,
      )
      .toString();
}