Skip to content

Commit

Permalink
Fix: Pagination not working on pull to refresh (#213)
Browse files Browse the repository at this point in the history
* Fix: Pagination not working on pull to refresh

* Change  _sortOption to Last_Created
  • Loading branch information
umareko authored Jan 15, 2024
1 parent fd59d20 commit 68afeb2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
26 changes: 16 additions & 10 deletions lib/presentation/screen/community_feed/community_feed_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,9 @@ class _CommunityFeedScreenState extends State<CommunityFeedScreen> {
.onError((error, stackTrace) {});
});

WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
postLiveCollection.loadNext();
});


scrollcontroller.addListener(pagination);


// _controller = PagingController(
// pageFuture: (token) => AmitySocialClient.newPostRepository()
Expand Down Expand Up @@ -127,7 +125,6 @@ class _CommunityFeedScreenState extends State<CommunityFeedScreen> {
.types(_dataType)
.tags(_tags)
.sortBy(_sortOption)
.onlyParent(true)
.build());

postLiveCollection.getStreamController().stream.listen((event) {
Expand All @@ -137,6 +134,13 @@ class _CommunityFeedScreenState extends State<CommunityFeedScreen> {
});
}
});

WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
postLiveCollection.loadNext();
});

scrollcontroller.addListener(pagination);

}


Expand Down Expand Up @@ -207,7 +211,8 @@ class _CommunityFeedScreenState extends State<CommunityFeedScreen> {
// });

postLiveCollection.reset();
postLiveCollection.getFirstPageRequest();
postLiveCollectionInit();

},
),
),
Expand Down Expand Up @@ -240,9 +245,9 @@ class _CommunityFeedScreenState extends State<CommunityFeedScreen> {
_sortOption = AmityPostSortOption.LAST_CREATED;
}

postLiveCollectionInit();

postLiveCollection.reset();
postLiveCollection.getFirstPageRequest();
postLiveCollectionInit();
},
),
),
Expand All @@ -261,7 +266,8 @@ class _CommunityFeedScreenState extends State<CommunityFeedScreen> {
_tags = [];
}
postLiveCollection.reset();
postLiveCollection.getFirstPageRequest();
postLiveCollectionInit();

});
},
),
Expand All @@ -275,7 +281,7 @@ class _CommunityFeedScreenState extends State<CommunityFeedScreen> {
? RefreshIndicator(
onRefresh: () async {
postLiveCollection.reset();
postLiveCollection.getFirstPageRequest();
postLiveCollectionInit();
},
child: ListView.builder(
controller: scrollcontroller,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: flutter_social_sample_app
description: Demonstrates how to use the flutter_application_1 plugin.

version: 1.1.7+22
version: 1.1.13+28

environment:
sdk: ">=2.17.0 <3.0.0"
Expand Down

0 comments on commit 68afeb2

Please sign in to comment.