Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Edson Bueno
    @EdsonBueno
    @heshesh2010 I'll need to see more of your code.
    Mohamed Zenadi
    @zeapo
    Hey aall, thanks for the awesome plugin :)
    I was wondering if there was a way to trigger a rebuild ?
    For instance, i'd like that after one action, to update an item in the list and avoid reloading the whole list, keep the position in the scroll and have a rebuild (due to the itme change)
    Edson Bueno
    @EdsonBueno

    Hi @zeapo
    Try using the value property from PagingController:

    _pagingController.value = PagingState(
      nextPageKey: nextPageKey,
      error: null,
      itemList: updatedList,
     );

    Don't mind about reloading the entire list. Flutter will take care of checking what items actually changed.

    I don't think you'll lose your scroll position using the method above. Still, if that happens, check out PageStorageKey from Flutter.

    Mohamed Zenadi
    @zeapo
    @EdsonBueno Thanks for the reply. I'll try this out!
    Mohamed Zenadi
    @zeapo

    same issue @EdsonBueno , If I do something simple like (for testing)

                _pagingController.itemList.removeAt(0);
                _pagingController.value = PagingState(
                  nextPageKey: _pagingController.nextPageKey,
                  error: null,
                  itemList: _pagingController.itemList,
                );

    It does not update the view, adding a .toList() when passing it makes it refresh. Or calling notifyListeners() on the controller. I dont mind adding toList() for small lists (my case), but wondering why :)

    Edson Bueno
    @EdsonBueno
    where do you add the .toList?
    I didn't know what you were doing to manipulate the list, but since you're directly changing the itemList from _pagingController, you don't need to use .value, just use notifyListeners() instead
    _pagingController.itemList.removeAt(0);
    _pagingController.notifyListeners();
    this will work as well
    Mohamed Zenadi
    @zeapo
                  itemList: _pagingController.itemList.toList(),
    the thing with notifyListeners() is that it's supposed to be only used from tests or from within the package change notfier itself or from tests. For the moment I'll rely on the toList() until I find a better way
    Edson Bueno
    @EdsonBueno
    @zeapo Here's the explanation:
    When you set a new value, it will only notify its listeners of the change, if the PagingState is different from the previous one. Unless you add .toList(), the reference of the itemList doesn't change, and so it doesn't know that it actually changed.
    That's why adding a toList() or a notifyListeners() works.
    Mohamed Zenadi
    @zeapo
    Thanks for the explanation \o
    Mark Ban
    @mban
    HI @EdsonBueno!
    I want to add a grouping function. Can you help me how to get start?
    Purusothaman Ramanujam
    @Purus
    @EdsonBueno All the examples are for using the future values. Is it possible for using streams? any experience and points that I should consider before trying on using a stream? Thanks in advance.
    Edson Bueno
    @EdsonBueno
    Hi @mban .
    Can you please clarify a bit more what it is that you want to achieve?
    Hi @Purus
    The example project has a screen using BLoC as the state management approach, tell me if that helps.
    Mark Ban
    @mban
    Hi @EdsonBueno!
    I want to resolve the grouping of items based on a specific field in the item. Here is an example Screenshot 2021-02-15 at 0.02.22.png
    How can I start this with your solution?
    Can i extend your library with this feature?
    Thank you in advance for your answer!
    Edson Bueno
    @EdsonBueno

    Hi @mban .
    Are your items being sorted on the API side? For example, before you get any "YESTERDAY" items, the API has to make sure all "TODAY" items are already delivered to you.
    Assuming this is true, the rest isn't that hard.

    Inside your itemBuilder callback, check if the current item is the first of its group by consulting PagingController.itemList. If it isn't, build and return the list item's widget as always. If it is, return a Column where the first element is your header and the second is your list item's widget.

    Mark Ban
    @mban
    @EdsonBueno thank you your answer!
    newway-cnp
    @newway-cnp
    Hey guys, I want to add new item top of the current list. How can I do that? I am adding the new value from riverpod provider. To the current list not it's not refresh.
    ProviderListener(
          provider: createCommentProvider,
          onChange: (context, state) {
            if (state.comment != null) {
              state.comment.isNew = true;
             _pagingController.itemList.add(state.comment);
            }
          },
    ........
    newway-cnp
    @newway-cnp
    I should do like this I think?
    if (value.state != null) {
              value.state.isNew = true;
              final newList = List.of(_pagingController.itemList);
    
              newList.add(value.state);
              _pagingController.itemList = newList;
            }
    Edson Bueno
    @EdsonBueno
    Hi @newway-cnp
    Yes, your code looks good
    Ruben Vereecken
    @rubenvereecken
    Hullo, I've got a very simple use case and I'm not sure if I read the interface correctly so I thought I'd ask here before I opened an issue/PR. Basically, I'd like to empty the pagingController. Take out all pages so I can start re-appending. But I couldn't find any setter-like methods that would allow me to write the state. Is this possible?
    Use case: I've got a disk cache. On page open, I re-append all old pages. This way the old data shows straight away. I also fire off a new request which fetches the first page from remote. When that returns, I want to signal to the page controller that I've got a single fresh page, so get rid of all old data and show the new page. Couldn't find any way to do it. A refresh isn't what I want: When I refresh straight away all my old data disappears, when I refresh after the first page is fetched, it results in another fetch (triggered by the page controller).
    If this is not possible but you're open to the use case, shall I write a PR?
    Ruben Vereecken
    @rubenvereecken
    I found I can use set value with a PagingStatus, I think I can try and use that instead of appendPage rather than in addition to because I think it triggers subsequent fetches
    Edson Bueno
    @EdsonBueno
    Hi @rubenvereecken .
    You're correct! The way to do it is using PagingController.value
    Ruben Vereecken
    @rubenvereecken
    @EdsonBueno Thanks, reading that interface was really insightful. Also made me realise the append methods really just refresh the whole list
    Ruben Vereecken
    @rubenvereecken
    This made me test some of the performance and I've got too many page requests which I can't explain.
    Page limit 2 and the PagedListView parent has a fixed height so it can only show up to 2 at a time. The pagingController has invisibleItemThreshold: 1. Still, I get three pages of length 2 fetched (third one is my last one so can't test more). The first two items are visible (page 1). Next two items are invisible (page 2). Still it fetches a third page, despite just over 2 items being invisible.
    Anything I should look out for to explain this?
    The same happens when I decrease the view to only show 1 item, I still get 3 pages (5 items worth)
    Am I accidentally triggering subsequent fetches? I don't do anything like notify request listeners
    Ruben Vereecken
    @rubenvereecken
    I looked at the underlying code and it turns out the PagedListView is building far more items than are visible, triggering subsequent fetches.. this is outside of my understanding I'm afraid, any idea why this happens?
    Edson Bueno
    @EdsonBueno
    Hi @rubenvereecken
    Are you using two scrollable views in the same direction? For example, a PagedListView inside a ScrollView or ListView?
    If you are, that could be the cause of the problem
    You should be using Flutter Slivers
    Ruben Vereecken
    @rubenvereecken
    @EdsonBueno You're amazing for getting back to me so quickly. I'm not, but I am using an Expanded TabBarView inside a Column which is the parent of the PagedListView... does that count?
    I've not worked with slivers much, happy to dig in if that's the promising route
    Ruben Vereecken
    @rubenvereecken
    (On another but interesting note, pagingController doesn't work as a getter - I'd put the logic in a mixin. Needs to be a property, I assume this is a ValueNotifier thing)
    Edson Bueno
    @EdsonBueno
    Are you using shrinkWrap: true in your PagedListView?
    I'll need a simplified version of your code to help you more than this
    Ruben Vereecken
    @rubenvereecken

    Are you using shrinkWrap: true in your PagedListView?

    I'm not, no

    Don't worry, don't want you to have to solve all of my issues, just wanted to know what was expeted behaviour. I'll take a closer look and if I still can't turn anything up or I find something relevant to the library I'll report back
    (might be a while though)
    Ruben Vereecken
    @rubenvereecken
    This really is a great library
    Edson Bueno
    @EdsonBueno
    Nice! Thank you @rubenvereecken
    sm2017
    @sm2017
    Do you have any sticky header example? I want to have a side sticky, In a chat view I want to stick avatar of user
    Edson Bueno
    @EdsonBueno
    @sm2017 No, I don't! I'm sorry