replaceLastPathName method

String replaceLastPathName(
  1. String replacePathName
)

替换最后路径名 (示例:http://xxxx/xx/[name?...|name2 -> newName?...]) replacePathName替换路径名

Implementation

String replaceLastPathName(String replacePathName) {
  if ([this, replacePathName].hasEmptyElement) {
    return "";
  }
  Uri uri = Uri.parse(this!);
  List<String> segments = List.from(uri.pathSegments);
  segments[segments.length - 1] = replacePathName;
  return uri.replace(pathSegments: segments).toString();
}