Files
kent_logistics_app/lib/providers/chat_unread_provider.dart
Abhishek Mali bb81269140 chat support
2025-12-15 11:10:52 +05:30

35 lines
676 B
Dart

import 'package:flutter/material.dart';
class ChatUnreadProvider extends ChangeNotifier {
int _unreadCount = 0;
bool _chatOpen = false;
int get unreadCount => _unreadCount;
bool get isChatOpen => _chatOpen;
/// 📩 Called when ADMIN sends message
void increment() {
if (!_chatOpen) {
_unreadCount++;
notifyListeners();
}
}
/// 👁 Called when chat screen is opened
void setChatOpen(bool open) {
_chatOpen = open;
if (open) {
_unreadCount = 0; // reset badge when user opens chat
}
notifyListeners();
}
/// 🔁 Manual reset (optional)
void reset() {
_unreadCount = 0;
notifyListeners();
}
}