Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Pagination not working on pull to refresh #213

Merged
merged 2 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading