getSecureStorage method

Future<BiometricStorageFile?> getSecureStorage(
  1. String key
)

Implementation

Future<BiometricStorageFile?> getSecureStorage(String key) async {
  if (await authenticate()) {
    try {
      return BiometricStorage().getStorage(
        key,
        options: StorageFileInitOptions(
          authenticationValidityDurationSeconds: 10, // Optional: Re-authenticate after a timeout
        ),
      );
    } catch (e) {
      // Handle errors in accessing or initializing the secure storage
      return null;
    }
  } else {
    // Authentication failed or was cancelled
    return null;
  }
}