canonicalPath function

String canonicalPath(
  1. String path
)

path made absolute, normalized, and with symbolic links resolved when it exists, so two spellings of one directory compare equal.

Implementation

String canonicalPath(String path) {
  final absolute = p.normalize(p.absolute(path));
  final directory = Directory(absolute);
  if (directory.existsSync()) {
    return p.normalize(directory.resolveSymbolicLinksSync());
  }
  return absolute;
}