buildUserMessage static method Null safety

Command buildUserMessage(
  1. String channelUrl,
  2. UserMessageParams params,
  3. String requestId
)

Implementation

static Command buildUserMessage(
  String channelUrl,
  UserMessageParams params,
  String requestId,
) {
  List<String>? mentionedUserList;
  if (params.mentionedUsers != null) {
    mentionedUserList = params.mentionedUsers!.map((e) => e.userId).toList();
  }
  final payload = <String, dynamic>{
    'channel_url': channelUrl,
    'created_at': DateTime.now().millisecondsSinceEpoch,
    'mentioned_user_ids': params.mentionedUserIds ?? mentionedUserList,
  };

  payload.addAll(params.toJson());

  return Command(
    cmd: CommandString.userMessage,
    payload: payload,
    requestId: requestId,
  );
}