init method
dynamic
init(})
Implementation
init(
BuildContext context, {
String? jid,
bool isUser = false,
bool isFromStarred = false,
String? messageId, required bool showChatDeliveryIndicator,
}) async {
this.context = context;
this.showChatDeliveryIndicator = showChatDeliveryIndicator;
var userJid = SessionManagement.getChatJid().checkNull();
if (jid != null) {
nJid = jid;
debugPrint("parameter :$jid");
if (nJid != null) {
userJid = jid;
}
if (isFromStarred && messageId != null) {
starredChatMessageId = messageId;
}
}
debugPrint('userJid $userJid');
getProfileDetails(userJid).then((value) {
if (value.jid != null) {
SessionManagement.setChatJid(Constants.emptyString);
profile_(value);
ready();
checkAdminBlocked();
}
}).catchError((o) {
debugPrint('error $o');
});
setAudioPath();
filteredPosition.bindStream(filteredPosition.stream);
ever(filteredPosition, (callback) {
lastPosition(callback.length);
//chatList.refresh();
});
chatList.bindStream(chatList.stream);
ever(chatList, (callback) {});
isUserTyping.bindStream(isUserTyping.stream);
///Commenting this, bcz this executed only when value is changed to true or false. if started typing value changed to true.
///Then after some interval, if we type again the value remains true so this is not calling
///Changing to below messageController.addListener()
/*ever(isUserTyping, (callback) {
mirrorFlyLog("typing ", callback.toString());
if (callback) {
sendUserTypingStatus();
DeBouncer(milliseconds: 2100).run(() {
sendUserTypingGoneStatus();
});
} else {
sendUserTypingGoneStatus();
}
});*/
messageController.addListener(() {
mirrorFlyLog("typing", "typing..");
sendUserTypingStatus();
debugPrint('User is typing');
deBouncer.cancel();
deBouncer.run(() {
debugPrint("DeBouncer");
sendUserTypingGoneStatus();
});
});
}