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
- Current User is Not authorized
recreating same Thread
- 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...