addParametersToUrl function

Uri addParametersToUrl(
  1. Uri url,
  2. Map<String, String>? parameters
)

Implementation

Uri addParametersToUrl(Uri url, Map<String, String>? parameters) {
  if (parameters == null) return url;

  String paramUrl = url.origin + url.path;

  Map<String, String> newParameters = {};

  url.queryParameters.forEach((key, value) {
    newParameters[key] = value;
  });

  parameters.forEach((key, value) {
    newParameters[key] = value;
  });

  return Uri.parse(buildUrlString(paramUrl, newParameters));
}