goToP2pChat<T extends Object?> function
Future<T?>
goToP2pChat<T extends Object?>(
- BuildContext context,
- String userId, {
- int? anchorDate,
- NIMMessage? message,
Implementation
Future<T?> goToP2pChat<T extends Object?>(BuildContext context, String userId,
{int? anchorDate, NIMMessage? message}) async {
var conversationId =
(await NimCore.instance.conversationIdUtil.p2pConversationId(userId))
.data!;
final shouldOpenBotSubsession = AIRobotManager.instance.isRobot(userId);
if (ChatKitUtils.isDesktopOrWeb && _desktopChatNavigator != null) {
Navigator.popUntil(context, (route) => route.isFirst);
_desktopChatNavigator!(
conversationId,
forceLinearChat: false,
topicContext: null,
);
return null;
}
if (shouldOpenBotSubsession) {
return _pushBotSubsessionList(
context,
conversationId,
NIMConversationType.p2p,
);
}
if (IMKitRouter.instance.enableGoRouter) {
return context.pushNamed(RouterConstants.PATH_CHAT_PAGE, extra: {
'conversationId': conversationId,
'conversationType': NIMConversationType.p2p,
'anchor': message,
'anchorDate': anchorDate,
});
}
return Navigator.pushNamed(context, RouterConstants.PATH_CHAT_PAGE,
arguments: {
'conversationId': conversationId,
'conversationType': NIMConversationType.p2p,
'anchor': message,
'anchorDate': anchorDate,
});
}