goToP2pChat<T extends Object?> function

Future<T?> goToP2pChat<T extends Object?>(
  1. BuildContext context,
  2. String userId, {
  3. int? anchorDate,
  4. NIMMessage? message,
})

跳转到P2P会话页面 userId 会话ID anchorDate 锚点日期 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!;

  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,
      });
}