Fix create wallet folder on startup

This commit is contained in:
poka 2021-01-29 03:11:24 +01:00
parent f0417407e0
commit e402be8cca
2 changed files with 9 additions and 11 deletions

View File

@ -51,6 +51,12 @@ class HomeProvider with ChangeNotifier {
Future getAppPath() async {
appPath = await getApplicationDocumentsDirectory();
walletsDirectory = Directory('${appPath.path}/wallets');
bool isWalletFolderExist = await walletsDirectory.exists();
if (!isWalletFolderExist) {
await Directory(walletsDirectory.path).create();
}
}
T getRandomElement<T>(List<T> list) {

View File

@ -13,15 +13,7 @@ class MyWalletsProvider with ChangeNotifier {
return false;
}
var walletsFolder = new Directory("${appPath.path}/wallets/");
bool isWalletFolderExist = walletsFolder.existsSync();
if (!isWalletFolderExist) {
Directory(walletsFolder.path).createSync();
}
List contents = walletsFolder.listSync();
List contents = walletsDirectory.listSync();
if (contents.length == 0) {
print('No wallets detected');
return false;
@ -64,8 +56,8 @@ class MyWalletsProvider with ChangeNotifier {
final bool _answer = await _confirmDeletingAllWallets(context);
if (_answer) {
walletsDirectory.deleteSync(recursive: true);
walletsDirectory.createSync();
await walletsDirectory.delete(recursive: true);
await walletsDirectory.create();
Navigator.pop(context);
}
return 0;