createURLString method

String createURLString(
  1. String path, {
  2. Map<String, String> params = const <String, String>{},
  3. bool? useHttps,
  4. bool? includeLibraryParams,
})

createURLString generates imgix url with optional query parameters.

  • If useHttps is given, default setting(shouldUseHttpsByDefault) is overridden.
  • If includeLibraryParams is given, default setting(_shouldIncludeLibParamByDefault) is overridden.

Implementation

String createURLString(String path,
    {Map<String, String> params = const <String, String>{},
    bool? useHttps,
    bool? includeLibraryParams}) {
  path = path.sanitizedPath;
  params = _joinWithMetaParams(params, includeLibParam: includeLibraryParams);
  var queryParams = buildParams(params);
  if (_signKey?.isNotEmpty ?? false) {
    queryParams = withSignature(path, queryParams, _signKey!);
  }
  final delimiter = queryParams.isEmpty ? '' : '?';
  if (useHttps == null) {
    return _urlPrefix() + _domain + path + delimiter + queryParams;
  } else {
    final urlPrefix = useHttps ? 'https://' : 'http://';
    return urlPrefix + _domain + path + delimiter + queryParams;
  }
}