getDocumentPath method
Implementation
Future<List<FileSystemEntity>> getDocumentPath() async {
var files = <FileSystemEntity>[];
var completer = new Completer<List<FileSystemEntity>>();
String path = await OpenDocument.getPathDocument();
String nameApp = await OpenDocument.getNameFolder();
if (filePath.split("//").last != nameApp) {
path = filePath;
} else {
path = await OpenDocument.getPathDocument();
}
Directory dir = new Directory(path);
var lister = dir.list(recursive: false);
lister.listen(
(file) {
files.add(file);
CustomFileSystemEntity().map[file] = false;
},
onDone: () {
lastPaths.add(path);
files.sort(
(a, b) => b.statSync().modified.compareTo(a.statSync().modified));
completer.complete(files);
},
);
notifyListeners();
return completer.future;
}