import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; import '../models/shop_model.dart'; class ShopProvider with ChangeNotifier { ShopModel? _shop; ShopModel? get shop => _shop; final String _boxName = 'shopBox'; ShopProvider() { _loadOrCreateDummyShop(); } void _loadOrCreateDummyShop() async { final box = await Hive.openBox(_boxName); if (box.isNotEmpty) { _shop = box.getAt(0); } else { // Dummy data _shop = ShopModel( id: '1', shopName: "Omkara Car Wash Center", email: "omkara@gmail.com", mobile: "8617019854", image: "assets/images/shop_image.jpg", address: "Bidhannagar, Kolkata, pin-700017", ); await box.add(_shop!); } notifyListeners(); } Future setShop(ShopModel shop) async { _shop = shop; notifyListeners(); final box = await Hive.openBox(_boxName); await box.clear(); // Keep only one shop await box.add(shop); } Future logout() async { _shop = null; notifyListeners(); final box = await Hive.openBox(_boxName); await box.clear(); } }