buildFileMessage static method Null safety

Command buildFileMessage(
  1. {required String channelUrl,
  2. required FileMessageParams params,
  3. required String? requestId,
  4. List? thumbnails,
  5. bool? requireAuth}
)

Implementation

static Command buildFileMessage({
  required String channelUrl,
  required FileMessageParams params,
  required String? requestId,
  List<dynamic>? thumbnails,
  bool? requireAuth,
}) {
  final payload = <String, dynamic>{
    'channel_url': channelUrl,
    'require_auth': requireAuth,
  };

  payload.addAll(params.toJson());

  payload['thumbnails'] = thumbnails;
  payload['created_at'] = DateTime.now().millisecondsSinceEpoch;

  payload.removeWhere((key, value) => value == null);
  return Command(
    cmd: CommandString.fileMessage,
    payload: payload,
    requestId: requestId,
  );
}