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
- Apple OAuth Scopes
Hi Hi, I've configured sign in with apple and this is the response i'm getting from apple once i've signed in. I cant find anywhere I set scopes. I remember se...
- Sign In With Apple OAuth Help
Hi All! I've got a flutter & appwrite app which Im trying to use sign in with apple for. I already have sign in with google working and the function is the sam...
- [SOLVED] OAuth With Google & Flutter
Hi all, I'm trying to sign in with google and it all goes swimmingly until the call back. I get a new user created on the appwrite dashboard however the flutte...