mirror of
https://github.com/aljazceru/breez-sdk-liquid.git
synced 2025-12-22 00:14:25 +01:00
Update example app on Flutter plugin (#220)
* Update example app on Flutter plugin * Expose `empty_wallet_cache` through Dart bindings (#224)
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_breez_liquid_example/services/keychain.dart';
|
||||
|
||||
class CredentialsManager {
|
||||
static const String accountMnemonic = "account_mnemonic";
|
||||
|
||||
final KeyChain keyChain;
|
||||
|
||||
CredentialsManager({required this.keyChain});
|
||||
|
||||
Future storeMnemonic({required String mnemonic}) async {
|
||||
try {
|
||||
await _storeMnemonic(mnemonic);
|
||||
debugPrint("Stored credentials successfully");
|
||||
} catch (err) {
|
||||
throw Exception(err.toString());
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> restoreMnemonic() async {
|
||||
try {
|
||||
String mnemonicStr = await keyChain.read(accountMnemonic) ?? "";
|
||||
debugPrint("Restored credentials successfully");
|
||||
return mnemonicStr;
|
||||
} catch (err) {
|
||||
throw Exception(err.toString());
|
||||
}
|
||||
}
|
||||
|
||||
// Helper methods
|
||||
Future<void> _storeMnemonic(String mnemonic) async {
|
||||
await keyChain.write(accountMnemonic, mnemonic);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user