storeChatIfNot method
- ChatModel chat
override
Creates the chat if it does not exist.
Implementation
@override
Future<ChatModel> storeChatIfNot(ChatModel chat) {
var chatExists = _chats.any((element) => element.id == chat.id);
if (!chatExists) {
chat.id = chat.hashCode.toString();
_chats.add(chat);
_chatsController.add([..._chats]);
notifyListeners();
debugPrint('Chat stored: $chat');
} else {
debugPrint('Chat already exists: $chat');
}
return Future.value(chat);
}