This is a client for the access to the secure storage service.
It's base on FlutterSecureStorage package.
Add the following to your pubspec.yaml
file:
dependencies:
secure_storage_client: ^0.0.1
git:
url: https://github.com/arcas0803/secure_storage_client.git
ref: main
import 'package:secure_storage_client/secure_storage_client.dart';
final secureStorage = SecureStorage();
secureStorage.read(key: 'your_key');
final secureStorage = SecureStorage();
secureStorage.write(key: 'your_key', value: 'your_value');
final secureStorage = SecureStorage();
secureStorage.delete(key: 'your_key');
final secureStorage = SecureStorage();
secureStorage.clean();
It's possible to enable the logger to see the logs of the client.
Just pass the logger
parameter to the constructor.
final logger = Logger();
final secureStorage = SecureStorage(logger: logger);
It's possible to handle telemetry events passing to methods to the constructor.
final secureStorage = SecureStorage(
FutureOr<void> Function(Failure)? telemetryOnError,
FutureOr<void> Function()? telemetryOnSuccess,
);
Telemetry on error is called when an error occurs.
Telemetry on success is called when the method is executed successfully.
The exceptions available are:
-
SecureStorageReadFailure
when the read method fails. -
SecureStorageWriteFailure
when the write method fails. -
SecureStorageKeyNotFoundFailure
when the key is not found. -
SecureStorageValueNotFoundFailure
when the value is not found. -
SecureStorageIntializationFailure
when the initialization fails.
There is an class called SecureStorageFailureUtil
with a method called getFailureNameUI
to get a user friendly message from the exception.
final failureName = SecureStorageFailureUtil.getFailureNameUI(
context: context,
failure:failure);