goToChatPage<T extends Object?> function

Future<T?> goToChatPage<T extends Object?>(
  1. BuildContext context,
  2. String conversationId,
  3. NIMConversationType type, {
  4. NIMMessage? message,
  5. int? anchorDate,
})

Implementation

Future<T?> goToChatPage<T extends Object?>(
    BuildContext context, String conversationId, NIMConversationType type,
    {NIMMessage? message, int? anchorDate}) async {
  // 桌面端:通过回调切换会话,不 push 新页面
  if (ChatKitUtils.isDesktopOrWeb && _desktopChatNavigator != null) {
    Navigator.popUntil(context, (route) => route.isFirst);
    _desktopChatNavigator!(conversationId);
    return null;
  }

  if (IMKitRouter.instance.enableGoRouter) {
    return context.pushNamed(RouterConstants.PATH_CHAT_PAGE, extra: {
      'conversationId': conversationId,
      'conversationType': type,
      'anchor': message,
      'anchorDate': anchorDate,
    });
  }
  return Navigator.pushNamed(context, RouterConstants.PATH_CHAT_PAGE,
      arguments: {
        'conversationId': conversationId,
        'conversationType': type,
        'anchor': message,
        'anchorDate': anchorDate,
      });
}