import 'package:flutter/cupertino.dart'; import '../../models/local_notification_model.dart'; // class NotificationSingleton extends ChangeNotifier{ // List localNotifs=[]; // static final NotificationSingleton _index=NotificationSingleton._internal(); // NotificationSingleton._internal(); // factory NotificationSingleton(){ // return _index; // } // addNotif(NotificationsModel notif){ // localNotifs.add(notif); // notifyListeners(); // } // NotificationsModel? getNotif(String notifId){ // var index= localNotifs.indexWhere((element) => element.id==notifId); // if(index!=-1){ // return localNotifs[index]; // } // return null; // } // // disposeSingleton() { // localNotifs=[]; // } // } // final notificationSingleton= NotificationSingleton(); class NotificationSingleton extends ChangeNotifier{ List localNotifs=[]; bool reservationNotifs=false; bool chatNotifs=false; static final NotificationSingleton _index=NotificationSingleton._internal(); NotificationSingleton._internal(); factory NotificationSingleton(){ return _index; } addNotif(LocalNotificationModel notif){ localNotifs.add(notif); notifyListeners(); } LocalNotificationModel? getNotif(String notifId){ var index= localNotifs.indexWhere((element) => element.id==notifId); if(index!=-1){ return localNotifs[index]; } return null; } deleteChatNotifs(){ final index=localNotifs.indexWhere((element) => element.chat!=null && element.chat!="null"); if(index!=-1){ localNotifs.removeAt(index); chatNotifs=false; } Future.delayed(Duration.zero, () { notifyListeners(); }); } getChatNotifs(){ final index=localNotifs.indexWhere((element) => element.chat!=null&& element.chat!="null"); if(index!=-1){ chatNotifs= true; }else{ chatNotifs= false; } notifyListeners(); } } final notificationSingleton= NotificationSingleton();