onInit method
Called immediately after the widget is allocated in memory. You might use this to initialize something for the controller.
Implementation
@override
void onInit() {
super.onInit();
//* *//
final findCurrentAccountController = Get.find<AccountUserController>();
log("Current AccountUser :: ${findCurrentAccountController.currentUserAccounts.value.user.value.displayName}");
//* *//
//Bellekteki paylaşımları yükle
if (cachedChatList != null) {
chatList.value ??= [];
chatList.value = cachedChatList;
filteredchatList.value = cachedChatList;
}
getchat(fetchRestart: true);
final socketController = Get.find<SocketioController>();
socketController.onChatUpdated = (chat) {
// Chat güncellemesi burada işlenir
bool chatisthere = chatList.value!.any(
(chatList) =>
chatList.user.userID == chat.user.userID &&
chatList.chatType == chat.chatType,
);
if (!chatisthere) {
chatList.value!.add(chat);
} else {
Chat currentChat = chatList.value!.firstWhere(
(chatList) =>
chatList.user.userID == chat.user.userID &&
chatList.chatType == chat.chatType,
);
currentChat.messages.value ??= [];
currentChat.messages.value!.add(chat.lastmessage!.value);
currentChat.lastmessage = Rx<ChatMessage>(chat.lastmessage!.value);
currentChat.chatNotification.value = chat.chatNotification.value;
currentChat.messages.refresh();
}
updateChatList();
};
}