sendMessage function

Future<void> sendMessage({
  1. String messageText = "",
  2. String url = '',
  3. required String userId,
  4. required String name,
  5. required String profile,
})

Implementation

Future<void> sendMessage({
  String messageText = "",
  String url = '',
  required String userId,
  required String name,
  required String profile,
}) async {
  ChatMessage dummyMessage = ChatMessage(
    text: messageText,
    ownerId: userId,
    createdOn: DateTime.now(),
    ownerName: name,
    ownerProfile: profile,
    url: url,
  );
  if (messageText.isNotEmpty || url.isNotEmpty) {
    DocumentReference messageRef = _chatRoomCollection.doc();
    await messageRef.set(dummyMessage.toJson());
  }
}