
I have this code that is called inside the init
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
initialization(context);
_realtimeSynchronisation();
});
}```
**_realtimeSynchronisation**
```_realtimeSynchronisation() {
print('SYNC CALLED');
ref.watch(getLatestChatMsgProvider).when(
data: (data) {
final message = MessageAppwrite.fromJson(data.payload);
final document = Document.fromMap(data.payload);
var event = '';
if (data.events.contains('databases.*.collections.${Strings.collectionMessagesId}.documents.*.create')) {
event = 'create';
} else if (data.events.contains('databases.*.collections.${Strings.collectionMessagesId}.documents.*.delete')) {
event = 'delete';
} else if (data.events.contains('databases.*.collections.${Strings.collectionMessagesId}.documents.*.update')) {
event = 'update';
} else {
event = 'loading';
}
print('outer income');
if ((message.senderUserId == myUserId || message.receiverUserId == myUserId) && (message.senderUserId == friendUserId || message.receiverUserId == friendUserId)) {
print('incomes here');
print('Message Sent is ${message.message}');
print('Event $event');
messageNotifier?.saveMessage(message, document, event);
}
},
error: (error, stk) => ErrorText(error: error.toString()),
loading: () => print('SYNC CALLED how'),
);
setState(() {});
}```
Everything is working but it's not showing up in view

What’s not showing up where?

i want to update my view

if i call the _realtimeSynchronisation() function inside the build() function, it will trigger the realtime functions multiple time

so i thought initialising it inside the initState would be better

So what is working, and what isn’t?

if i make a call to the _realtimeSynchronisation() the flutter view will be updated but the issues is that it will be called multiple time
Recommended threads
- Realtime Disconnects and Error: INVALID_...
Hi! I just want to ask here if there's any workaround with the disconnect issues we're encountering when subscribing to realtime events in react native using ex...
- Redirect URL sends HTTP instead of HTTPS...
I am not sure since when this issue is present, but my Google and Apple redirect URI are no longer pointing to the HTTPS redirect URI when I try to use OAuth. ...
- Failing to run document operations on sd...
Could someone point me in the right direction I'm going in cirlces. I have a problem with sdks and my self-hosted server in production (for ~3 years) I have bee...
