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
- total parameter not working correctly in...
Hello Appwrite team, I'm experiencing issues with the total parameter in the listRows() method (TablesDB) across multiple SDKs. **Issue 1**: Node.js SDK (node...
- Subscription Problem
I'm making an app in RN with Expo and Appwrite and there's a functionality which allows the user to create a task/test (i'll be reffering to them collectively a...
- Relationship lists aren't showing
In flutter, when I perform a listRows function for my table which contains various relationships in addition to normal data, I am not getting the relationships ...