sure
Hello I have attached below all my code related to userProfiel realtime update, I have tried for several hours on my own and still cant find a solution. Please help
final appwriteRealtimeProvider = Provider((ref) { final client = ref.watch(appwriteClientProvider); return Realtime(client); }); // ------------------- Stream<RealtimeMessage> getLatestProfileData(); final userApiProvider = Provider((ref) { final db = ref.watch(appwriteDatabaseProvider); final realTime = ref.watch(appwriteRealtimeProvider); return UserApi(db: db, realtime: realTime); }); // -------------------- final getLatestUserProfileDataProvider = StreamProvider((ref) { final userApi = ref.watch(userApiProvider); return userApi.getLatestProfileData(); }); // ------------------------ import '../controller/user_profile_controller.dart'; import '../widget/user_profile.dart';
class UserProfileView extends ConsumerWidget { static route(UserModel userModel) => MaterialPageRoute( builder: (context) => UserProfileView(userModel: userModel), ); const UserProfileView({super.key, required this.userModel});
final UserModel userModel;
@override Widget build(BuildContext context, WidgetRef ref) { UserModel copyOfUser = userModel; return Scaffold( body: ref.watch(getLatestUserProfileDataProvider).when( data: (data) { if (data.events.contains( 'databases.*.collections.${AppwriteConstants.usersCollection}.documents.${userModel.uid}.update')) { copyOfUser = UserModel.fromMap(data.payload); return UserProfile(userModel: copyOfUser); } return UserProfile(userModel: copyOfUser); }, error: (error, stackTrace) => ErrorText(error: error.toString()), loading: () { return UserProfile(userModel: copyOfUser); // return Loader(); }, ), ); } }
Btw, it's best to use 3 back ticks with multi-line code. See https://www.markdownguide.org/extended-syntax/#syntax-highlighting
Also...what exactly is wrong? What do you expect is happening vs the actual behavior?
When I update my profile and and profile picture I expect it to reflect on the ui, it only happends when i restartt my app
Where are you calling subscribe?
Aahhh!!! I am not sure where to do that
😬
I will aditionally add my link to repo, https://github.com/nuaiman/flutter_appwrite_twitter_clone
Ref.when() is probably not the right approach, unless you change up the ref.
As mentioned in the docs, you have to subscribe and then listen to the stream: https://appwrite.io/docs/realtime
Ohhhh
I still dont understand, what to write
Look at how the subscription is created and used
Okay, i will have a look at it and report back
@Steven hello
I am stuck in a situation
I dont know what to write for a particular realTime
let me exlain
``
'databases.${AppwriteConstants.databaseId}.collections.${AppwriteConstants.chatsCollection}.documents.'
I want to only get realtime document where the conversationId is matching with me
@Binyamin
please don't randomly tag people as it can be disruptive
you'll have to filter this client side.
You might want to 👍🏼 this issue: https://github.com/appwrite/appwrite/issues/2490
Recommended threads
- Which flutter SDK version for Self Hoste...
Hi all, Is there a good way to figure out which version of flutter SDK and Dart SDK is current for latest available self-hosted 1.8.0 ? I know new features are...
- redirect_uri errors on flutter client
Hi all, I'm using the flutter client for my app to do appwrite auth and use the JWTs to send to my backend. When I try to sign in with SSO, I get this: https:/...
- Problem with getting rows from related t...
Hi, I migrated the Appwrite SDK to 1.8.0 and the package in my Flutter app to version ^20.3.2. I noticed one thing is different. Previously, when I got a JSON r...