createPath static method

String createPath(
  1. String path, [
  2. Iterable? segments
])

Creates a path by concatenating the provided path and segments.

If segments is null or empty, the original path is returned. Otherwise, the path is concatenated with each segment from segments separated by a forward slash ('/').

Implementation

static String createPath(String path, [Iterable? segments]) {
  if (segments == null || segments.isEmpty) {
    return path;
  }
  final list = segments.map((e) => '/$e');
  return path + list.join();
}