sendTextMessage method
Sends a text message to the specified chat.
Implementation
@override
Future<void> sendTextMessage({
required String chatId,
required String text,
}) async {
var chat = (chatOverviewService as LocalChatOverviewService)
.chats
.firstWhere((element) => element.id == chatId);
var message = ChatTextMessageModel(
sender: const ChatUserModel(
id: '3',
firstName: 'ico',
lastName: 'nica',
imageUrl: 'https://picsum.photos/100/200',
),
timestamp: DateTime.now(),
text: text,
);
await (chatOverviewService as LocalChatOverviewService).updateChat(
chat.copyWith(
messages: [...?chat.messages, message],
lastMessage: message,
lastUsed: DateTime.now(),
),
);
chat.messages?.add(message);
_cumulativeMessages.add(message);
notifyListeners();
return Future.value();
}