-
-
Notifications
You must be signed in to change notification settings - Fork 117
Add a deleteAndDispose API to allow storage reinitialisation at runtime #138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -290,6 +290,12 @@ abstract class BiometricStorage extends PlatformInterface { | |
| String content, | ||
| PromptInfo promptInfo, | ||
| ); | ||
|
|
||
| @protected | ||
| Future<void> dispose( | ||
| String name, | ||
| PromptInfo promptInfo, | ||
| ); | ||
| } | ||
|
|
||
| class MethodChannelBiometricStorage extends BiometricStorage { | ||
|
|
@@ -425,6 +431,14 @@ class MethodChannelBiometricStorage extends BiometricStorage { | |
| ..._promptInfoForCurrentPlatform(promptInfo), | ||
| })); | ||
|
|
||
| @override | ||
| Future<void> dispose(String name, PromptInfo promptInfo) => _transformErrors( | ||
| _channel.invokeMethod('dispose', <String, dynamic>{ | ||
| 'name': name, | ||
| ..._promptInfoForCurrentPlatform(promptInfo), | ||
| }), | ||
| ); | ||
|
Comment on lines
+435
to
+440
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This adds a method channel call for Please ensure that the native implementations are added to this pull request. The native |
||
|
|
||
| Map<String, dynamic> _promptInfoForCurrentPlatform(PromptInfo promptInfo) { | ||
| // Don't expose Android configurations to other platforms | ||
| if (Platform.isAndroid) { | ||
|
|
@@ -501,4 +515,12 @@ class BiometricStorageFile { | |
| /// Delete the content of this storage. | ||
| Future<void> delete({PromptInfo? promptInfo}) => | ||
| _plugin.delete(name, promptInfo ?? defaultPromptInfo); | ||
|
|
||
| /// Delete the content of this storage and dispose of the storage instance. | ||
| /// After calling this method, this BiometricStorageFile instance should not be used. | ||
| /// A subsequent call to BiometricStorage().getStorage() with the same name will create a new instance. | ||
| Future<void> deleteAndDispose({PromptInfo? promptInfo}) async { | ||
| await delete(promptInfo: promptInfo); | ||
| await _plugin.dispose(name, promptInfo ?? defaultPromptInfo); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block of code for deleting and disposing the different storages is quite repetitive. You can refactor this to reduce duplication and improve maintainability by iterating over a list of the storages. This makes the code cleaner and easier to modify if more storage types are added in the future.