import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; import 'package:pwa_ios/model/interaction_config_data.dart'; class HiveDataRepository extends ChangeNotifier { Box _hiveBox; // Use the correct type for your Hive box HiveDataRepository(this._hiveBox); List getAllDataFromHive() { print("Stored_ALL_valuesssss : ${_hiveBox.values.toList()}"); print( "Stored_ALL_valuesssss_leangthhh : ${_hiveBox.values.toList().length}"); return _hiveBox.values.toList(); } Future openHiveBox() async { _hiveBox = await Hive.openBox('InteractionConfigDataBox'); } Future closeHiveBox() async { _hiveBox.close(); } List getAllofflineData() { return _hiveBox.values.toList(); } Future addOfflineData(InteractionConfigData data, int id) async { // _hiveBox = await Hive.openBox('InteractionDataBox'); await _hiveBox.put(id, data); notifyListeners(); } Future getNextAutoIncrementValue() async { var counterBox = await Hive.openBox('counterBox'); if (!counterBox.containsKey('counter')) { counterBox.put('counter', 0); } int? counter = counterBox.get('counter'); counterBox.put('counter', counter! + 1); await counterBox.close(); return counter; } }