goToChatAndKeepHome function
void
goToChatAndKeepHome(
- BuildContext context,
- String conversationId,
- NIMConversationType type, {
- 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
});
}
}