asDirectory property

Directory? get asDirectory

Return a Directory if the string is a directory or file path, otherwise return null.

If the string is a file path, it returns the parent directory.

Implementation

Directory? get asDirectory {
  if (FileSystemEntity.isDirectorySync(fixPath)) {
    return Directory(fixPath);
  } else if (FileSystemEntity.isFileSync(fixPath)) {
    return File(fixPath).parent;
  } else {
    return null;
  }
}