getWalletsInWalletsDir static method
This method returns a list of wallet file names in the wallet directory with the given walletDirName and filtered by the given filteredExtension.
Implementation
static Future<List<String>> getWalletsInWalletsDir(String walletDirName, String filteredExtension) async{
try {
Directory appDocDir = await getApplicationDocumentsDirectory();
Directory walletDir = Directory(path.join(appDocDir.path,walletDirName));
List<String> wallets = [];
List<FileSystemEntity> wFiles = walletDir.listSync()
.where((e) => e.path.endsWith(filteredExtension))
.toList()
..sort((l, r) => r.statSync().accessed.compareTo(l.statSync().accessed));
wallets = wFiles.map((e) =>
path.basename(e.path)).toList();
List<String> wTemps = [];
wallets.forEach((walletFileName) {wTemps.add(walletFileName.split(filteredExtension)[0]); });
return wTemps;
} on PathNotFoundException catch (_) {
return [];
}
}