diff --git a/packages/flutter_timeline_firebase/lib/src/service/firebase_post_service.dart b/packages/flutter_timeline_firebase/lib/src/service/firebase_post_service.dart index 2ec3e87..76a6c54 100644 --- a/packages/flutter_timeline_firebase/lib/src/service/firebase_post_service.dart +++ b/packages/flutter_timeline_firebase/lib/src/service/firebase_post_service.dart @@ -13,8 +13,9 @@ import 'package:flutter_timeline_firebase/src/models/firebase_user_document.dart import 'package:flutter_timeline_interface/flutter_timeline_interface.dart'; import 'package:uuid/uuid.dart'; -class FirebaseTimelinePostService extends TimelinePostService - with TimelineUserService { +class FirebaseTimelinePostService + with TimelineUserService, ChangeNotifier + implements TimelinePostService { FirebaseTimelinePostService({ required TimelineUserService userService, FirebaseApp? app, @@ -34,6 +35,9 @@ class FirebaseTimelinePostService extends TimelinePostService final Map _users = {}; + @override + List posts = []; + @override Future createPost(TimelinePost post) async { var postId = const Uuid().v4(); @@ -119,14 +123,16 @@ class FirebaseTimelinePostService extends TimelinePostService .get() : await _db.collection(_options.timelineCollectionName).get(); - posts = []; + var fetchedPosts = []; for (var doc in snapshot.docs) { var data = doc.data(); var user = await _userService.getUser(data['creator_id']); var post = TimelinePost.fromJson(doc.id, data).copyWith(creator: user); - posts.add(post); + fetchedPosts.add(post); } + posts = fetchedPosts; + notifyListeners(); return posts; }