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();
if (!Get.isRegistered<FloatChatStore>()) {
Get.put<FloatChatStore>(FloatChatStore());
}
focusNode.addListener(_handleFocusChange);
listener = V2TimAdvancedMsgListener(
onRecvMessageRevoked: (String messageId) {
FloatChatStore.to.messageList.removeWhere((message) {
return message.msgID == messageId;
});
},
onRecvNewMessage: (V2TimMessage message) {
if (message.elemType == MessageElemType.V2TIM_ELEM_TYPE_TEXT) {
String? text = message.textElem!.text;
FloatChatStore.to.messageList.add(
MessageModel(
msgID: message.msgID!,
userName: message.nickName ?? message.sender ?? "",
text: text ?? "",
),
);
}
},
);
TencentImSDKPlugin.v2TIMManager
.getMessageManager()
.addAdvancedMsgListener(listener: listener);
}