rename method
Renames the last path segment and returns a new path URI.
Implementation
PathUri rename(String name) {
if (name.contains('/')) {
throw Exception('Path names must not contain /');
}
return PathUri(
isAbsolute: isAbsolute,
isDirectory: isDirectory,
pathSegments: pathSegments.isNotEmpty
? pathSegments.rebuild(
(b) => b
..removeLast()
..add(name),
)
: BuiltList(),
);
}