这看起来有点麻烦
var fileExists =
new File(path).existsSync() ||
new Directory(path).existsSync() ||
new Link(path).existsSync()
是否有更短或更好的方式?
答案 0 :(得分:11)
更简短的方法是
import 'dart:io';
FileSystemEntity.typeSync(path) != FileSystemEntityType.notFound
另见https://github.com/dart-lang/sdk/issues/2883#issuecomment-108317456