parentPath method
Uri is divided by separator
and moved one level up.
Uriをseparator
で分割し一つ上の階層に移動します。
final path = Uri.parse("aaaa/bbbb/cccc/dddd");
final parentPath = path.parentPath(); // "aaaa/bbbb/cccc"
Implementation
Uri parentPath({String separator = "/"}) {
if (isEmpty) {
return this;
}
final path = toString().trimString(separator);
return Uri.parse(path.replaceAll(_tail, "").trimStringRight(separator));
}