sendMessage method

Future<FirestackMessage> sendMessage({
  1. required String channelId,
  2. required String body,
  3. String type = 'text',
  4. Map<String, dynamic>? metadata,
  5. int? replyToId,
})

Send a message to a channel.

Implementation

Future<FirestackMessage> sendMessage({
  required String channelId,
  required String body,
  String type = 'text',
  Map<String, dynamic>? metadata,
  int? replyToId,
}) async {
  final response = await _client.post('channels/$channelId/messages', body: {
    'body': body,
    'type': type,
    if (metadata != null) 'metadata': metadata,
    if (replyToId != null) 'reply_to_id': replyToId,
  });
  return FirestackMessage.fromJson(response['data'] as Map<String, dynamic>);
}