Fix moar linter warnings

This commit is contained in:
vishnukvmd 2021-07-23 00:11:58 +05:30
parent 899ab66d00
commit eb9de99730
15 changed files with 37 additions and 41 deletions

View file

@ -4,7 +4,7 @@ import 'package:photos/core/cache/lru_map.dart';
import 'package:photos/models/file.dart';
class FileLruCache {
static LRUMap<String, io.File> _map = LRUMap(25);
static final LRUMap<String, io.File> _map = LRUMap(25);
static io.File get(File file) {
return _map.get(file.tag());

View file

@ -1,9 +1,9 @@
import 'dart:collection';
typedef EvictionHandler<K, V>(K key, V value);
typedef EvictionHandler<K, V> = Function(K key, V value);
class LRUMap<K, V> {
final LinkedHashMap<K, V> _map = new LinkedHashMap<K, V>();
final LinkedHashMap<K, V> _map = LinkedHashMap<K, V>();
final int _maxSize;
final EvictionHandler<K, V> _handler;

View file

@ -5,7 +5,7 @@ import 'package:photos/core/constants.dart';
import 'package:photos/models/file.dart';
class ThumbnailLruCache {
static LRUMap<String, Uint8List> _map = LRUMap(1000);
static final LRUMap<String, Uint8List> _map = LRUMap(1000);
static Uint8List get(File photo, [int size]) {
return _map.get(photo.generatedID.toString() +

View file

@ -126,7 +126,7 @@ class CollectionsDB {
Future<List<Collection>> getAllCollections() async {
final db = await instance.database;
final rows = await db.query(table);
final collections = List<Collection>();
final collections = <Collection>[];
for (final row in rows) {
collections.add(_convertToCollection(row));
}
@ -157,7 +157,7 @@ class CollectionsDB {
}
Map<String, dynamic> _getRowForCollection(Collection collection) {
var row = new Map<String, dynamic>();
var row = <String, dynamic>{};
row[columnID] = collection.id;
row[columnOwner] = collection.owner.toJson();
row[columnEncryptedKey] = collection.encryptedKey;

View file

@ -69,14 +69,14 @@ class MemoriesDB {
}
Map<String, dynamic> _getRowForSeenMemory(Memory memory, int timestamp) {
var row = new Map<String, dynamic>();
var row = <String, dynamic>{};
row[columnFileID] = memory.file.generatedID;
row[columnSeenTime] = timestamp;
return row;
}
Map<int, int> _convertToSeenTimes(List<Map<String, dynamic>> rows) {
final seenTimes = Map<int, int>();
final seenTimes = <int, int>{};
for (final row in rows) {
seenTimes[row[columnFileID]] = int.parse(row[columnSeenTime]);
}

View file

@ -65,14 +65,14 @@ class PublicKeysDB {
}
Map<String, dynamic> _getRow(PublicKey key) {
var row = new Map<String, dynamic>();
var row = <String, dynamic>{};
row[columnEmail] = key.email;
row[columnPublicKey] = key.publicKey;
return row;
}
List<PublicKey> _convertRows(List<Map<String, dynamic>> rows) {
final keys = List<PublicKey>();
final keys = <PublicKey>[];
for (final row in rows) {
keys.add(PublicKey(row[columnEmail], row[columnPublicKey]));
}

View file

@ -50,7 +50,7 @@ class UploadLocksDB {
Future<void> acquireLock(String id, String owner, int time) async {
final db = await instance.database;
final row = new Map<String, dynamic>();
final row = <String, dynamic>{};
row[_columnID] = id;
row[_columnOwner] = owner;
row[_columnTime] = time;

View file

@ -17,7 +17,7 @@ class SyncStatusUpdate extends Event {
this.reason = "",
this.error,
}) {
this.timestamp = DateTime.now().microsecondsSinceEpoch;
timestamp = DateTime.now().microsecondsSinceEpoch;
}
@override

View file

@ -102,7 +102,7 @@ class Collection {
factory Collection.fromMap(Map<String, dynamic> map) {
if (map == null) return null;
final sharees = (map['sharees'] == null || map['sharees'].length == 0)
? List<User>()
? <User>[]
: List<User>.from(map['sharees'].map((x) => User.fromMap(x)));
return Collection(
map['id'],
@ -196,7 +196,7 @@ class CollectionAttributes {
}
Map<String, dynamic> toMap() {
final map = Map<String, dynamic>();
final map = <String, dynamic>{};
if (encryptedPath != null) {
map['encryptedPath'] = encryptedPath;
}

View file

@ -81,7 +81,7 @@ class File {
}
Map<String, dynamic> getMetadata() {
final metadata = Map<String, dynamic>();
final metadata = <String, dynamic>{};
metadata["localID"] = localID;
metadata["title"] = title;
metadata["deviceFolder"] = deviceFolder;

View file

@ -2,8 +2,8 @@ import 'package:flutter/foundation.dart';
import 'package:photos/models/file.dart';
class SelectedFiles extends ChangeNotifier {
final files = Set<File>();
final lastSelections = Set<File>();
final files = <File>{};
final lastSelections = <File>{};
void toggleSelection(File file) {
if (files.contains(file)) {
@ -12,7 +12,7 @@ class SelectedFiles extends ChangeNotifier {
files.add(file);
}
lastSelections.clear();
lastSelections.add(file);
lastSelections.add(file);
notifyListeners();
}

View file

@ -54,13 +54,10 @@ class BillingService {
}
Future<BillingPlans> getBillingPlans() {
if (_future == null) {
_future = _dio
.get(_config.getHttpEndpoint() + "/billing/plans")
.then((response) {
return BillingPlans.fromMap(response.data);
});
}
_future ??=
_dio.get(_config.getHttpEndpoint() + "/billing/plans").then((response) {
return BillingPlans.fromMap(response.data);
});
return _future;
}
@ -86,7 +83,7 @@ class BillingService {
);
return Subscription.fromMap(response.data["subscription"]);
} catch (e) {
throw e;
rethrow;
}
}
@ -104,7 +101,7 @@ class BillingService {
return subscription;
} on DioError catch (e) {
_logger.severe(e);
throw e;
rethrow;
}
}
@ -124,7 +121,7 @@ class BillingService {
);
return response.data["usage"];
} catch (e) {
throw e;
rethrow;
}
}

View file

@ -26,7 +26,7 @@ class LocalSyncService {
static const kDownloadedFileIDsKey = "downloaded_file_ids";
static const kInvalidFileIDsKey = "invalid_file_ids";
LocalSyncService._privateConstructor() {}
LocalSyncService._privateConstructor();
static final LocalSyncService instance =
LocalSyncService._privateConstructor();
@ -41,7 +41,6 @@ class LocalSyncService {
PhotoManager.addChangeCallback((value) {
_logger.info("Something changed on disk");
callback();
});
PhotoManager.startChangeNotify();
}

View file

@ -122,7 +122,7 @@ class SyncService {
}
_logger.severe("backup failed", e, s);
Bus.instance.fire(SyncStatusUpdate(SyncStatus.error));
throw e;
rethrow;
} finally {
_existingSync.complete(successful);
_existingSync = null;
@ -212,7 +212,7 @@ class SyncService {
return response.data["size"];
} catch (e) {
_logger.severe(e);
throw e;
rethrow;
}
}

View file

@ -106,7 +106,7 @@ class UserService {
await dialog.hide();
Navigator.of(context).popUntil((route) => route.isFirst);
} else {
throw new Exception("log out action failed");
throw Exception("log out action failed");
}
} catch (e) {
_logger.severe(e);
@ -129,7 +129,7 @@ class UserService {
await dialog.hide();
if (response != null && response.statusCode == 200) {
showToast("email verification successful!");
var page;
Widget page;
final String twoFASessionID = response.data["twoFactorSessionID"];
if (twoFASessionID != null && twoFASessionID.isNotEmpty) {
page = TwoFactorAuthenticationPage(twoFASessionID);
@ -180,7 +180,7 @@ class UserService {
await _config.setKeyAttributes(result.keyAttributes);
} catch (e) {
_logger.severe(e);
throw e;
rethrow;
}
}
@ -205,7 +205,7 @@ class UserService {
await _config.setKeyAttributes(keyAttributes);
} catch (e) {
_logger.severe(e);
throw e;
rethrow;
}
}
@ -229,7 +229,7 @@ class UserService {
await _config.setKeyAttributes(keyAttributes);
} catch (e) {
_logger.severe(e);
throw e;
rethrow;
}
}
@ -417,13 +417,13 @@ class UserService {
} catch (e, s) {
await dialog.hide();
_logger.severe(e, s);
throw e;
rethrow;
}
}
Future<bool> enableTwoFactor(
BuildContext context, String secret, String code) async {
var recoveryKey;
Uint8List recoveryKey;
try {
recoveryKey = await getOrCreateRecoveryKey(context);
} catch (e) {
@ -507,7 +507,7 @@ class UserService {
return response.data["status"];
} catch (e, s) {
_logger.severe(e, s);
throw e;
rethrow;
}
}
@ -524,7 +524,7 @@ class UserService {
} catch (e, s) {
await dialog.hide();
_logger.severe(e, s);
throw e;
rethrow;
}
}
final recoveryKey = _config.getRecoveryKey();