Bläddra i källkod

Fix linter suggestions

vishnukvmd 4 år sedan
förälder
incheckning
1d9e67c6c6
1 ändrade filer med 7 tillägg och 10 borttagningar
  1. 7 10
      lib/core/configuration.dart

+ 7 - 10
lib/core/configuration.dart

@@ -65,7 +65,7 @@ class Configuration {
     _secureStorage = FlutterSecureStorage();
     _secureStorage = FlutterSecureStorage();
     _documentsDirectory = (await getApplicationDocumentsDirectory()).path;
     _documentsDirectory = (await getApplicationDocumentsDirectory()).path;
     _tempDirectory = _documentsDirectory + "/temp/";
     _tempDirectory = _documentsDirectory + "/temp/";
-    final tempDirectory = new io.Directory(_tempDirectory);
+    final tempDirectory = io.Directory(_tempDirectory);
     try {
     try {
       final currentTime = DateTime.now().microsecondsSinceEpoch;
       final currentTime = DateTime.now().microsecondsSinceEpoch;
       if (tempDirectory.existsSync() &&
       if (tempDirectory.existsSync() &&
@@ -196,7 +196,7 @@ class Configuration {
       attributes.memLimit,
       attributes.memLimit,
       attributes.opsLimit,
       attributes.opsLimit,
     );
     );
-    var key;
+    Uint8List key;
     try {
     try {
       key = CryptoUtil.decryptSync(Sodium.base642bin(attributes.encryptedKey),
       key = CryptoUtil.decryptSync(Sodium.base642bin(attributes.encryptedKey),
           kek, Sodium.base642bin(attributes.keyDecryptionNonce));
           kek, Sodium.base642bin(attributes.keyDecryptionNonce));
@@ -240,7 +240,7 @@ class Configuration {
 
 
   Future<void> recover(String recoveryKey) async {
   Future<void> recover(String recoveryKey) async {
     final keyAttributes = getKeyAttributes();
     final keyAttributes = getKeyAttributes();
-    var masterKey;
+    Uint8List masterKey;
     try {
     try {
       masterKey = await CryptoUtil.decrypt(
       masterKey = await CryptoUtil.decrypt(
           Sodium.base642bin(keyAttributes.masterKeyEncryptedWithRecoveryKey),
           Sodium.base642bin(keyAttributes.masterKeyEncryptedWithRecoveryKey),
@@ -248,7 +248,7 @@ class Configuration {
           Sodium.base642bin(keyAttributes.masterKeyDecryptionNonce));
           Sodium.base642bin(keyAttributes.masterKeyDecryptionNonce));
     } catch (e) {
     } catch (e) {
       _logger.severe(e);
       _logger.severe(e);
-      throw e;
+      rethrow;
     }
     }
     await setKey(Sodium.bin2base64(masterKey));
     await setKey(Sodium.bin2base64(masterKey));
   }
   }
@@ -261,9 +261,7 @@ class Configuration {
   }
   }
 
 
   String getToken() {
   String getToken() {
-    if (_cachedToken == null) {
-      _cachedToken = _preferences.getString(tokenKey);
-    }
+    _cachedToken ??= _preferences.getString(tokenKey);
     return _cachedToken;
     return _cachedToken;
   }
   }
 
 
@@ -308,7 +306,7 @@ class Configuration {
     if (_preferences.containsKey(foldersToBackUpKey)) {
     if (_preferences.containsKey(foldersToBackUpKey)) {
       return _preferences.getStringList(foldersToBackUpKey).toSet();
       return _preferences.getStringList(foldersToBackUpKey).toSet();
     } else {
     } else {
-      return Set<String>();
+      return <String>{};
     }
     }
   }
   }
 
 
@@ -341,8 +339,7 @@ class Configuration {
   }
   }
 
 
   Future<void> setKeyAttributes(KeyAttributes attributes) async {
   Future<void> setKeyAttributes(KeyAttributes attributes) async {
-    await _preferences.setString(
-        keyAttributesKey, attributes == null ? null : attributes.toJson());
+    await _preferences.setString(keyAttributesKey, attributes?.toJson());
   }
   }
 
 
   KeyAttributes getKeyAttributes() {
   KeyAttributes getKeyAttributes() {