The common super class for File, Directory, and Link objects.
FileSystemEntity objects are returned from directory listing operations. To determine if a FileSystemEntity is a File, a Directory, or a Link perform a type check:
if (entity is File) (entity as File).readAsStringSync();
You can also use the type or typeSync methods to determine the type of a file system object.
Most methods in this class occur in synchronous and asynchronous pairs, for example, exists and existsSync. Unless you have a specific reason for using the synchronous version of a method, prefer the asynchronous version to avoid blocking your program.
Here's the exists method in action:
entity.exists().then((isThere) {
isThere ? print('exists') : print('non-existent');
});
Dart by Example provides additional task-oriented code samples that show how to use various API from the Directory class and the File class, both subclasses of FileSystemEntity.
I/O for Command-Line Apps, a section from A Tour of the Dart Libraries covers files and directories.
Write Command-Line Apps, a tutorial about writing command-line apps, includes information about files and directories.
Future<bool>
that completes with the result. [...]