splitPathToDirectories function
This function returns every Directory in the path independently
e.g:
path: /lib/user/share/var/foo
Directory: /
Directory: /lib/
Directory: /lib/user
Directory: /lib/user/share
....
Implementation
List<Directory> splitPathToDirectories(String fullPath) {
List<Directory> splittedPath = [];
Directory fullPathDir = Directory(fullPath);
splittedPath.add(fullPathDir);
for (int i = 0; i == pathlib.split(fullPath).length; i++) {
splittedPath.add(fullPathDir.parent);
fullPathDir = fullPathDir.parent;
}
return splittedPath.reversed.toList();
}