createOrGetFolderInWalletDir static method
This method asynchronously retrieves the wallet directory path by calling getWalletDir, creates a target folder path by joining the wallet directory path with the provided wallet name, and checks if the folder exists. If it exists, the path is returned. If it doesn't exist, the folder is created and its path is returned.
Implementation
static Future<String> createOrGetFolderInWalletDir(String walletDirName,String walletName) async {
//Get this App Document Directory
final Directory walletDir = await getWalletDir(walletDirName);
String finalPathTargetFolder = path.join(walletDir.path, walletName);
//App Document Directory + folder name
final Directory subWalletDir = Directory(finalPathTargetFolder);
if (await subWalletDir.exists()) {
//if folder already exists return path
return subWalletDir.path;
} else {
//if folder not exists create folder and then return its path
final Directory subWalletNewDir = await subWalletDir.create(recursive: true);
return subWalletNewDir.path;
}
}