]> git.proxmox.com Git - flutter/proxmox_login_manager.git/blame - lib/proxmox_password_store.dart
login form: use const constructor to improve performance
[flutter/proxmox_login_manager.git] / lib / proxmox_password_store.dart
CommitLineData
62145778
DC
1import 'package:biometric_storage/biometric_storage.dart';
2
3Future<bool> canSavePassword() async {
4 return await BiometricStorage().canAuthenticate() ==
5 CanAuthenticateResponse.success;
6}
7
8Future<void> savePassword(String id, String password) async {
9 if (await canSavePassword()) {
10 BiometricStorageFile store = await BiometricStorage().getStorage(id);
11 await store.write(password);
12 }
13}
14
15Future<String?> getPassword(String id) async {
16 String? password;
17 if (await canSavePassword()) {
18 BiometricStorageFile store = await BiometricStorage().getStorage(id);
19 password = await store.read();
20 }
21
22 return password;
23}
24
25Future<void> deletePassword(String id) async {
26 if (await canSavePassword()) {
27 BiometricStorageFile store = await BiometricStorage().getStorage(id);
28 await store.delete();
29 }
30}