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
- 500 Internal Error when Project is opene...
After migrating from 1.6.1 to 1.7.4 I noticed this strange behaviour: When I open a project in a separate tab I get a 500 internal error. However, then I simpl...
- Custom Topic sent from Function (with sc...
Can I send a message on a custom topic? So clients can subscribe to them?
- CORS error only on tables db api After u...
I've recently updated my self hosted appwrite instance to the 1.8.0 and updated my frontend with the tables db apis but strangely, even if I'm able to log in, g...