chat method
- ChatId id, {
- RouteAs mode = RouteAs.replace,
- ChatItemId? itemId,
- ChatDirectLinkSlug? link,
- bool search = false,
Changes router location to the Routes.chats page.
If push is true, then location is pushed to the router location stack.
Implementation
void chat(
ChatId id, {
RouteAs mode = RouteAs.replace,
ChatItemId? itemId,
ChatDirectLinkSlug? link,
bool search = false,
}) {
switch (mode) {
case RouteAs.insteadOfLast:
routes.removeLast();
push('${Routes.chats}/$id');
break;
case RouteAs.replace:
go('${Routes.chats}/$id');
break;
case RouteAs.push:
push('${Routes.chats}/$id');
break;
}
arguments = {'itemId': itemId, 'link': link, 'search': search};
// TODO: Might not be the best thing to do it.
if (search) {
final List<ChatController> chats = Get.findAll<ChatController>();
for (var e in chats) {
if (e.id == id || (id.isLocal && e.user?.id == id.userId)) {
e.toggleSearch();
}
}
}
}