Not able to fetch all communities list for a loggedIn user (Flutter))

I have created two communities from Amity Dashboard and now on my app trying to get list of communities and unable to fetch and no error is displayed. Code i have written is:

final _amityCommunities = <AmityCommunity>[];
 late PagingController<AmityCommunity> _communityController;

 void queryCommunities() {
   _communityController = PagingController(
     pageFuture: (token) => AmitySocialClient.newCommunityRepository()
         .getPagingData(token: token, limit: 20),
     pageSize: 20,
       () {
         if (_communityController.error == null) {
           //handle results, we suggest to clear the previous items
           //and add with the latest _controller.loadedItems
           //update widgets
         } else {
           debugPrint('Error : ${_communityController.error}');
           //error on pagination controller
           //update widgets

SDK version is : 0.21.0
Flutter version is : 3.10.0

Hey there! Just wanted to confirm if the loggedIn user has already joined those two communities. When you attempted to fetch, were you able to get any of them? Or none of them?

No, the loggedIn user didn’t join any community.
When attempted to fetch, got no result neither any error.

Got it, so you are trying to query communities and display it to users to explore their community options - let me pass this to our team to help check. Thank you :))

Hi, please try the sample code provided below:

void queryCommunities() {
    print("query commy");
    _communityController = AmitySocialClient.newCommunityRepository()
        .getPagingData(token: null, limit: 20)
        .then((value) {

@amitysupport Thanks this is working for me.
But above shared code doesn’t have pagination implementation. How can i implement pagination to this data?

Please see how to implement pagination below:

  1. Declare pageToken class variable, this variable will be used to keep track of pagination token
  2. Assign the pageToken variable into getPagingData as seen in the code snippet below
final result = await AmitySocialClient.newCommunityRepository()
          .getPagingData(token: _pageToken, limit: 20);
  1. Once you get the result, it will also comes with token as well, assign it to pageToken. Please find the code snippet below for a setState example
  setState(() {
        _pageToken = result.token;
        _isLoading = false;
  1. Now all you have to do is pagination support on the UI and trigger query function, the pageToken will handle the rest of the pagination