ChatViewModel constructor
ChatViewModel(
- String conversationId,
- NIMConversationType conversationType, {
- bool showReadAck = true,
- NIMMessage? anchorMessage,
- int? findAnchorDate,
- ChatUIConfig? chatUIConfig,
- Future<
NIMResult< ? conversationEntryFuture,int> > - QuickCommentListLoader? quickCommentListLoader,
- QuickCommentAdder? quickCommentAdder,
- QuickCommentRemover? quickCommentRemover,
- MessageListConnectivityChecker? messageListConnectivityChecker,
- MessageReactionConnectivityChecker? messageReactionConnectivityChecker,
- String? currentAccountIdProvider()?,
- @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());
}
}