parentPath method

String parentPath({
  1. String separator = "/",
})

String is divided by separator and moved one level up.

Stringseparatorで分割し一つ上の階層に移動します。

final path = "aaaa/bbbb/cccc/dddd";
final parentPath = path.parentPath(); // "aaaa/bbbb/cccc"

Implementation

String parentPath({String separator = "/"}) {
  if (isEmpty) {
    return this;
  }
  final path = trimString(separator);
  return path.replaceAll(_tail, "").trimStringRight(separator);
}