# Flutter: Unable to get post for different communities

**URL:** <https://forum.social.plus/t/flutter-unable-to-get-post-for-different-communities/811>\
**Category:** General\
**Created:** [July 10, 2023, 10:58am UTC](https://forum.social.plus/t/flutter-unable-to-get-post-for-different-communities/811 "2023-07-10T10:58:52Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![maddy0028](https://avatars.discourse-cdn.com/v4/letter/m/a5b964/32.png) [@maddy0028](https://forum.social.plus/u/maddy0028)\
**Post date:** [July 10, 2023, 10:58am UTC](https://forum.social.plus/t/flutter-unable-to-get-post-for-different-communities/811/1 "2023-07-10T10:58:52Z")

</div>

As per my use case, user can join multiple communities. I need to fetch all the posts from different community and show it at one screen. Is it possible to pass list of community ids and get all the posts available in those community using Amity? I have not find any documentation for this. Please help.

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [July 10, 2023, 2:19pm UTC](https://forum.social.plus/t/flutter-unable-to-get-post-for-different-communities/811/2 "2023-07-10T14:19:51Z")

</div>

Hi @maddy0028 , are you referring to the global feed: [https://docs.amity.co/social/feed/query-global-feed](https://docs.amity.co/social/feed/query-global-feed) ? This feed consolidates all posts from the communities that a user has joined.

---

<div class="post-metadata">

**Author:** ![maddy0028](https://avatars.discourse-cdn.com/v4/letter/m/a5b964/32.png) [@maddy0028](https://forum.social.plus/u/maddy0028)\
**Post date:** [July 11, 2023, 6:51am UTC](https://forum.social.plus/t/flutter-unable-to-get-post-for-different-communities/811/3 "2023-07-11T06:51:41Z")

</div>

Hi @SocialPlus_Support I have tried global feed, but I am not able to fetch posts added for different community. I am using below code:

\_globalController = PagingController(  
pageFuture: (token) {  
return AmitySocialClient.newFeedRepository()  
.getGlobalFeed()  
.getPagingData(token: token, limit: 20);  
},  
pageSize: 20,  
);

```
_globalController.addListener(
  () {
    if (_globalController.error == null) {
      _globalPosts ??= [];
      _globalController.loadedItems.forEach((element) {
        int index = _globalPosts!
            .indexWhere((post) => post.postId == element.postId);
        if (index < 0) {
          _globalPosts!.insert(0, element);
        } else {
          _globalPosts!.removeAt(index);
          _globalPosts!.insert(0, element);
        }
      });

      _globalPosts?.sort((a, b) => b.createdAt!.compareTo(a.createdAt!));
      Future.delayed(Duration(milliseconds: 500), () {
        notifyListeners();
      });
    } else {
      _globalController.retry();
    }
  },
);
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
  _globalController.fetchNextPage();
});

```

Let me know if I am missing something. Thanks

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [July 11, 2023, 11:07am UTC](https://forum.social.plus/t/flutter-unable-to-get-post-for-different-communities/811/4 "2023-07-11T11:07:22Z")

</div>

Understood. Just to clarify, are you specifically looking to fetch the posts from communities that a user has joined? Please note that this will not include the posts from other communities that the user is not a member of. Can you please confirm if this is the requirement you are referring to?

---

<div class="post-metadata">

**Author:** ![maddy0028](https://avatars.discourse-cdn.com/v4/letter/m/a5b964/32.png) [@maddy0028](https://forum.social.plus/u/maddy0028)\
**Post date:** [July 11, 2023, 11:24am UTC](https://forum.social.plus/t/flutter-unable-to-get-post-for-different-communities/811/5 "2023-07-11T11:24:20Z")

</div>

Yes @SocialPlus_Support you got my problem. I need to fetch posts from joined community by any user. I am not looking for posts which are available on other community which user has not joined.

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [July 11, 2023, 11:48am UTC](https://forum.social.plus/t/flutter-unable-to-get-post-for-different-communities/811/6 "2023-07-11T11:48:21Z")

</div>

Thank you for your clarification, may I know your sdk version as well?

---

<div class="post-metadata">

**Author:** ![maddy0028](https://avatars.discourse-cdn.com/v4/letter/m/a5b964/32.png) [@maddy0028](https://forum.social.plus/u/maddy0028)\
**Post date:** [July 12, 2023, 8:05am UTC](https://forum.social.plus/t/flutter-unable-to-get-post-for-different-communities/811/7 "2023-07-12T08:05:45Z")

</div>

Hi @SocialPlus_Support I am using amity\_sdk: ^0.21.0.

I have made some improvement, now I can fetch the global post from different communities(which user has joined), but it is not sorted. I don’t see any option to sort it while fetching from amity server. Is it sorted with some other field?

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [July 12, 2023, 11:49am UTC](https://forum.social.plus/t/flutter-unable-to-get-post-for-different-communities/811/8 "2023-07-12T11:49:47Z")

</div>

Hello, unfortunately, our SDK does not currently offer an option to sort the global feed. Currently, our global feed is sorted based on engagement. For more information on how the custom post ranking works, please refer to this section in our documentation: [Custom Post Ranking - Amity Docs](https://docs.amity.co/social/feed/custom-post-ranking#how-it-works)

If you would like to have the feed sorted by chronological order, please reach out to our support team by sending an email to: [support.asc@amity.co](mailto:support.asc@amity.co)
