LCOV - code coverage report
Current view: top level - lib/network/authentication - authentication_storage.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 5 5 100.0 %
Date: 2021-11-15 14:58:17 Functions: 0 0 -

          Line data    Source code
       1             : import 'dart:async';
       2             : 
       3             : import 'package:flutter_secure_storage/flutter_secure_storage.dart';
       4             : 
       5             : /// Providing an interface to store User Credentials across sessions
       6             : abstract class AuthenticationStorage {
       7             :   /// Saves [credential]
       8             :   /// You should not change [credential]
       9             :   /// If [credential] is `null` it means the credential is invalid and should be deleted
      10             :   FutureOr<void> saveCredential(String? credential);
      11             : 
      12             :   /// Called to return the credential
      13             :   /// This should return an unmodified version of the credential received via `saveCredential`
      14             :   FutureOr<String?> get credential;
      15             : }
      16             : 
      17             : /// Implementation of [AuthenticationStorage] based on [flutter_secure_storage](https://pub.dev/packages/flutter_secure_storage)
      18             : class FlutterSecureStorageCredentialStorage implements AuthenticationStorage {
      19             :   /// Creates a new AuthenticationStorage
      20          28 :   const FlutterSecureStorageCredentialStorage();
      21             : 
      22             :   static const _credentialKey = 'ApptiveGridCredential';
      23             : 
      24             :   final _flutterSecureStorage = const FlutterSecureStorage(
      25             :     aOptions: AndroidOptions(
      26             :       encryptedSharedPreferences: true,
      27             :     ),
      28             :   );
      29             : 
      30           1 :   @override
      31             :   FutureOr<String?> get credential =>
      32           2 :       _flutterSecureStorage.read(key: _credentialKey);
      33             : 
      34           1 :   @override
      35             :   FutureOr<void> saveCredential(String? credential) {
      36           2 :     _flutterSecureStorage.write(key: _credentialKey, value: credential);
      37             :   }
      38             : }

Generated by: LCOV version 1.15