NIMMessage.audioEmptyMessage constructor Null safety

NIMMessage.audioEmptyMessage(
  1. {required String sessionId,
  2. required NIMSessionType sessionType,
  3. required String filePath,
  4. required int fileSize,
  5. required int duration,
  6. String? displayName,
  7. NIMNosScene nosScene = NIMNosScenes.defaultIm}
)

Implementation

factory NIMMessage.audioEmptyMessage(
    {required String sessionId,
    required NIMSessionType sessionType,
    required String filePath,
    required int fileSize,
    required int duration,
    String? displayName,
    NIMNosScene nosScene = NIMNosScenes.defaultIm}) {
  /// The minimum time for display is 1 second.
  if (duration < 1000) duration = 1000;

  var extension = filePath.split('.').last;

  var audioAttachment = NIMAudioAttachment(
      path: filePath,
      size: fileSize,
      duration: duration,
      extension: extension,
      nosScene: nosScene);
  return NIMMessage(
      messageDirection: NIMMessageDirection.outgoing,
      messageType: NIMMessageType.audio,
      timestamp: new DateTime.now().millisecondsSinceEpoch,
      status: NIMMessageStatus.sending,
      sessionId: sessionId,
      sessionType: sessionType,
      messageAttachment: audioAttachment);
}