sendImageMessage method

  1. @override
Future<void> sendImageMessage({
  1. required String chatId,
  2. required Uint8List image,
})
override

Sends an image message to the specified chat.

Implementation

@override
Future<void> sendImageMessage({
  required String chatId,
  required Uint8List image,
}) async {
  var chat = (chatOverviewService as LocalChatOverviewService)
      .chats
      .firstWhere((element) => element.id == chatId);
  var message = ChatImageMessageModel(
    sender: const ChatUserModel(
      id: '3',
      firstName: 'ico',
      lastName: 'nica',
      imageUrl: 'https://picsum.photos/100/200',
    ),
    timestamp: DateTime.now(),
    imageUrl: 'https://picsum.photos/200/300',
  );

  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();
}