listFiles method
Implementation
Future<List<String>> listFiles() async {
final Directory dir = await _directory;
try {
return List<String>.from(
dir.listSync().where((file) => file is File).map(
(file) => file.path.split("/").last,
),
);
} on FileSystemException catch (e) {
if (e.osError!.errorCode != 2)
throw e; // if error is not "No such file or directory"
return [];
}
}