feat : buy in province all
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import 'i_local_storage.dart';
|
||||
|
||||
class HiveLocalStorage implements ILocalStorage {
|
||||
HiveLocalStorage() {
|
||||
Hive.initFlutter();
|
||||
@@ -43,6 +41,17 @@ class HiveLocalStorage implements ILocalStorage {
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
T? readBox<T>({required String boxName}) {
|
||||
try {
|
||||
Box? box = getBox(boxName);
|
||||
return box?.values as T?;
|
||||
} on Exception catch (e) {
|
||||
eLog(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> add({required String boxName, required dynamic value}) async {
|
||||
Box<dynamic>? box = getBox(boxName);
|
||||
@@ -50,10 +59,7 @@ class HiveLocalStorage implements ILocalStorage {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> addAll({
|
||||
required String boxName,
|
||||
required Iterable values,
|
||||
}) async {
|
||||
Future<void> addAll({required String boxName, required Iterable values}) async {
|
||||
Box<dynamic>? box = getBox(boxName);
|
||||
await box?.addAll(values);
|
||||
}
|
||||
@@ -76,20 +82,13 @@ class HiveLocalStorage implements ILocalStorage {
|
||||
Future<void> close(String boxName) async => await _boxes[boxName]?.close();
|
||||
|
||||
@override
|
||||
Future<void> deleteValue({
|
||||
required String boxName,
|
||||
required String key,
|
||||
}) async {
|
||||
Future<void> deleteValue({required String boxName, required String key}) async {
|
||||
Box<dynamic>? box = getBox(boxName);
|
||||
await box?.delete(key);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> save({
|
||||
required String boxName,
|
||||
required String key,
|
||||
required value,
|
||||
}) async {
|
||||
Future<void> save({required String boxName, required String key, required value}) async {
|
||||
Box<dynamic>? box = getBox(boxName);
|
||||
await box?.put(key, value);
|
||||
}
|
||||
@@ -101,11 +100,7 @@ class HiveLocalStorage implements ILocalStorage {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> saveAt({
|
||||
required String boxName,
|
||||
required int index,
|
||||
required value,
|
||||
}) async {
|
||||
Future<void> saveAt({required String boxName, required int index, required value}) async {
|
||||
Box<dynamic>? box = getBox(boxName);
|
||||
await box?.putAt(index, value);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ abstract class ILocalStorage<E> {
|
||||
|
||||
T? read<T>({required String boxName, required String key});
|
||||
|
||||
T? readBox<T>({required String boxName});
|
||||
|
||||
Future<void> deleteValue({required String boxName, required String key});
|
||||
|
||||
Future<void> add({required String boxName, required E value});
|
||||
|
||||
Reference in New Issue
Block a user