1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-09 06:18:49 +00:00

Some linting_tool updates and cleanup (#1279)

This commit is contained in:
Parker Lougheed
2022-05-22 23:48:16 -05:00
committed by GitHub
parent 50863c5b63
commit d6296157f4
24 changed files with 187 additions and 196 deletions

View File

@@ -10,7 +10,7 @@ class HiveService {
boxName,
);
List<T> existingProducts = await getBoxes(boxName);
final List<T> existingProducts = await getBoxes(boxName);
if (!existingProducts.contains(item)) {
await openBox.add(item);
@@ -24,9 +24,9 @@ class HiveService {
boxName,
);
List<T> existingProducts = await getBoxes(boxName);
final Set<T> existingProducts = Set.unmodifiable(await getBoxes(boxName));
for (var item in items) {
for (final item in items) {
if (!existingProducts.contains(item)) {
await openBox.add(item);
}
@@ -38,9 +38,9 @@ class HiveService {
boxName,
);
List<T> boxes = await getBoxes(boxName);
final List<T> boxes = await getBoxes(boxName);
for (var box in boxes) {
for (final box in boxes) {
if (box == item) {
await openBox.deleteAt(boxes.indexOf(item));
}
@@ -52,9 +52,9 @@ class HiveService {
boxName,
);
List<T> boxes = await getBoxes(boxName);
final List<T> boxes = await getBoxes(boxName);
for (var box in boxes) {
for (final box in boxes) {
if (box == item) {
await openBox.putAt(boxes.indexOf(item), newItem);
}
@@ -62,15 +62,13 @@ class HiveService {
}
static Future<List<T>> getBoxes<T>(String boxName, [String? query]) async {
List<T> boxList = [];
final openBox = await Hive.openLazyBox<T>(boxName);
int length = openBox.length;
final length = openBox.length;
for (int i = 0; i < length; i++) {
boxList.add(await openBox.getAt(i) as T);
}
final boxList = <T>[
for (int i = 0; i < length; i++) await openBox.getAt(i) as T
];
return boxList;
}