DirectoryItem.fromPath constructor

DirectoryItem.fromPath(
  1. String strPath
)

Implementation

factory DirectoryItem.fromPath(String strPath) {
  var separator = strPath.contains('/') ? '/' : '\\';
  var name = strPath.split(separator).length > 2
      ? strPath.split(separator).last
      : strPath;

  var dir = DirectoryItem(
      name: name,
      path: strPath,
      nativePath: strPath.codeUnits,
      size: 0,
      type: DirectoryItemType.directory,
      isSymbolicLink: false);

  return dir;
}