29 lines
847 B
Dart
29 lines
847 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');
|
|
|
|
hiveApiConstantsBox.addAll(hiveList);
|
|
}
|
|
|
|
static Future<bool> checkIfApiExists(
|
|
String api,
|
|
) async {
|
|
late Box<HiveApiConstants> hiveApiConstantsBox;
|
|
hiveApiConstantsBox =
|
|
await Hive.openBox<HiveApiConstants>('hiveApiConstants');
|
|
|
|
List<HiveApiConstants> list = hiveApiConstantsBox.values.toList();
|
|
return list.indexWhere(
|
|
(element) => element.functionName == api,
|
|
) ==
|
|
-1
|
|
? false
|
|
: true;
|
|
}
|
|
}
|