smartnsoft / flappy_search_bar

SearchBar widget to handle most of search cases
MIT License
172 stars 94 forks source link

Request - Add a event when the scroll meet the bottom #17

Open JoHwanhee opened 4 years ago

JoHwanhee commented 4 years ago

a small request,, for pagination. need a event when the scroll meet the bottom..

ThomasEcalle commented 4 years ago

Hi @JoHwanhee
First of all, I am sorry for the delay. The situation in my company (in France) with the Covid-19 has forced us to put our open source projects on the side for a moment... But I am back ! :)

I could give user access to such callback but I am not sure about the logic of pagination after. Indeed, the entire ListView will be built again with new values but you will loose previous one, no ?

I think that pagination is a great topic and I would like to work on it for the flappy_search_bar but I think that would deserve a lot more work to be enable to keep last search in memory and concat with new one.

Don't you agree ? I am not sure to be clear enough, sorry for my english :)

I'll try to be more present on this package, despite the difficult context that had lead us to change a lot the way we work here, sorry again for the delay :)

JoHwanhee commented 4 years ago

I really thank you for your reply. are you ok about Covid-19?

So you means, it is hard to work because to concat last data with new one?

I'm not sure why you're worried about keeping data in memory, i think no problem for memory. it is the issue about the user that use this Lib.

sagreine commented 3 years ago

You could capture it indirectly by wrapping SearchBar with something like this, coupled with pagination. more here: https://github.com/smartnsoft/flappy_search_bar/issues/40#issuecomment-751559884 just a novice on my end :)


NotificationListener<ScrollNotification>(
                onNotification: (notification) {
                  // if we're searching and have hit the bottom index.
                  if (search != "") {
                    if (notification.metrics.atEdge) {
                      if (notification.metrics.pixels != 0) {
                        var temp = _videos.length;
                        print(
                            "number of search results before getting next page: ${_videos.length}");
                        getDocumentsNext(context, search).then((value) {
                          print(
                              "number of search results after getting next page: ${_videos.length}");
                          if (temp != _videos.length) {
                            // we've updated the source we're pulling from, so the same search will give more data
                            _searchBarController.replayLastSearch();
                          }
                        });
                      }
                    }
                  }
                  return true;
                },
 child: SearchBar<ExerciseSet>(