ChatViewModel constructor

ChatViewModel(
  1. String conversationId,
  2. NIMConversationType conversationType, {
  3. bool showReadAck = true,
  4. NIMMessage? anchorMessage,
  5. int? findAnchorDate,
  6. ChatUIConfig? chatUIConfig,
  7. Future<NIMResult<int>>? conversationEntryFuture,
  8. QuickCommentListLoader? quickCommentListLoader,
  9. QuickCommentAdder? quickCommentAdder,
  10. QuickCommentRemover? quickCommentRemover,
  11. MessageListConnectivityChecker? messageListConnectivityChecker,
  12. MessageReactionConnectivityChecker? messageReactionConnectivityChecker,
  13. String? currentAccountIdProvider()?,
  14. @visibleForTesting bool initializeRuntime = true,
})

Implementation

ChatViewModel(
  this.conversationId,
  this.conversationType, {
  this.showReadAck = true,
  NIMMessage? anchorMessage,
  this.findAnchorDate,
  this.chatUIConfig,
  this.conversationEntryFuture,
  QuickCommentListLoader? quickCommentListLoader,
  QuickCommentAdder? quickCommentAdder,
  QuickCommentRemover? quickCommentRemover,
  MessageListConnectivityChecker? messageListConnectivityChecker,
  MessageReactionConnectivityChecker? messageReactionConnectivityChecker,
  String? Function()? currentAccountIdProvider,
  @visibleForTesting bool initializeRuntime = true,
})  : _quickCommentListLoader = quickCommentListLoader,
      _quickCommentAdder = quickCommentAdder,
      _quickCommentRemover = quickCommentRemover,
      _messageListConnectivityChecker = messageListConnectivityChecker,
      _messageReactionConnectivityChecker =
          messageReactionConnectivityChecker,
      _currentAccountIdProvider = currentAccountIdProvider,
      _runtimeInitialized = initializeRuntime {
  if (initializeRuntime) {
    _setNIMMessageListener();
    initData(anchorMessage: anchorMessage);
    //初始化语音播放器
    ChatAudioPlayer.instance.initAudioPlayer();
    showWarningTips = chatUIConfig?.warningWidgetBuilder != null;
    unawaited(_initHistoryReadPosition());
  }
}