31 lines
1006 B
Dart
31 lines
1006 B
Dart
import 'package:hive_flutter/hive_flutter.dart';
|
|
import 'package:konectar_events/model/hive_api_constants.dart';
|
|
|
|
class HiveOperations {
|
|
static Future<void> saveApiConstants(List<HiveApiConstants> hiveList) async {
|
|
late Box<HiveApiConstants> hiveApiConstantsBox;
|
|
hiveApiConstantsBox =
|
|
await Hive.openBox<HiveApiConstants>('hiveApiConstants');
|
|
print("DataAffing");
|
|
// hiveApiConstantsBox.clear();
|
|
hiveApiConstantsBox.addAll(hiveList);
|
|
}
|
|
|
|
static Future<bool> checkIfApiExists(String api, String moduleName) async {
|
|
late Box<HiveApiConstants> hiveApiConstantsBox;
|
|
hiveApiConstantsBox =
|
|
await Hive.openBox<HiveApiConstants>('hiveApiConstants');
|
|
|
|
List<HiveApiConstants> list = hiveApiConstantsBox.values.toList();
|
|
|
|
print("Show/HideApiList: $list");
|
|
return list.indexWhere(
|
|
(element) =>
|
|
element.functionName == api && element.module == moduleName,
|
|
) ==
|
|
-1
|
|
? false
|
|
: true;
|
|
}
|
|
}
|