goToChatAndKeepHome function

void goToChatAndKeepHome(
  1. BuildContext context,
  2. String conversationId,
  3. NIMConversationType type, {
  4. NIMMessage? message,
})

跳转到会话页面,并保持首页

Implementation

void goToChatAndKeepHome(
    BuildContext context, String conversationId, NIMConversationType type,
    {NIMMessage? message}) {
  if (IMKitRouter.instance.enableGoRouter) {
    // 先回到首页(清空栈)
    context.go('/');

    // 再 push ChatPage
    Future.microtask(() {
      context.push(
        RouterConstants.PATH_CHAT_PAGE,
        extra: {
          'conversationId': conversationId,
          'conversationType': type,
          'anchor': message
        },
      );
    });
  } else {
    Navigator.pushNamedAndRemoveUntil(
        context, RouterConstants.PATH_CHAT_PAGE, ModalRoute.withName('/'),
        arguments: {
          'conversationId': conversationId,
          'conversationType': type,
          'anchor': message
        });
  }
}