firstComponent property

File get firstComponent

Returns a File to the first component of the File's path, regardless of whether it is a directory or a file.

Implementation

File get firstComponent {
  List<String> elem = split(path);
  String result = elem.firstWhere((it) => it != "/", orElse: () => path);
  return File(result);
}