有没有更好的方法来查找存在的文件或目录?

Gün*_*uer 6 dart dart-io

这看起来有点麻烦

var fileExists = 
    new File(path).existsSync() || 
    new Directory(path).existsSync() || 
    new Link(path).existsSync() 
Run Code Online (Sandbox Code Playgroud)

有更短或更好的方式吗?

Gün*_*uer 13

更简短的方法是

import 'dart:io';

FileSystemEntity.typeSync(path) != FileSystemEntityType.notFound
Run Code Online (Sandbox Code Playgroud)

另见https://github.com/dart-lang/sdk/issues/2883#issuecomment-108317456