appendUriComponents method

Uri appendUriComponents(
  1. List<String> components, {
  2. required bool isDirectory,
})

Appends a list of path components to the URI.

Implementation

Uri appendUriComponents(List<String> components,
    {required bool isDirectory}) {
  var s = toString();
  if (s.endsWith('/')) {
    s = s.substring(0, s.length - 1);
  }
  for (final comp in components) {
    s += '/${Uri.encodeComponent(comp)}';
  }
  if (isDirectory) {
    s += '/';
  }
  return Uri.parse(s);
}