]>
Commit | Line | Data |
---|---|---|
62145778 DC |
1 | import 'package:biometric_storage/biometric_storage.dart'; |
2 | ||
3 | Future<bool> canSavePassword() async { | |
4 | return await BiometricStorage().canAuthenticate() == | |
5 | CanAuthenticateResponse.success; | |
6 | } | |
7 | ||
8 | Future<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 | ||
15 | Future<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 | ||
25 | Future<void> deletePassword(String id) async { | |
26 | if (await canSavePassword()) { | |
27 | BiometricStorageFile store = await BiometricStorage().getStorage(id); | |
28 | await store.delete(); | |
29 | } | |
30 | } |