splitLength method

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

Divides String by separator and returns the number of elements.

Stringseparatorで分割し、その要素数を返します。

final path = "aaaa/bbbb/cccc/dddd";
final length = path.splitLength(); // 4

Implementation

int splitLength({String separator = "/"}) {
  if (isEmpty) {
    return 0;
  }
  final paths = split(separator);
  final length = paths.length;
  return length;
}