Closed GregorySech closed 5 years ago
Hi! Thanks for reaching out. I've had a look, and it seems that you calling
setState(() {
loading = true;
});
is causing to update the widget. If you remove that it seems to work. Now that probably doesn't help because you want to display some loading indicator.
I'll need a way to get notified that new data has finished load so I'm thinking to add an extra parameter to the LazyLoadScrollView
, maybe isLoading
to check whether the list has been populated with new data.
Thoughts?
Sorry was a little busy.
In the end I just provided an empty callback if I was loading.
It does feel like a workaround so maybe having a parameter that "ignores" the callback on build might be a good idea.
If the callback returned a future maybe you could set the loadMoreStatus as stable after it completes instead of relying on didUpdateWidget
Another idea might be using the LazyLoadScrollView's child's (Value)Key to understand if that has been updated and the LazyLoadScrollView is stable again.
Something like this:
class LazyLoadScrollViewState extends State<LazyLoadScrollView> {
LoadingStatus loadMoreStatus = LoadingStatus.STABLE;
@override
void didUpdateWidget(LazyLoadScrollView oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.child.key == null || oldWidget.child.key != widget.child.key) {
loadMoreStatus = LoadingStatus.STABLE;
}
}
...
and on the "client" side it would be kind of like this:
LazyLoadScrollView(
child: ListView.builder(
key: ValueKey(documents.length),
itemCount: ...
Heya! Thanks for the feedback. I feel like the key
idea would be a bit brittle, and harder to debug.
Using an explicit parameter, is probably clearer to the user and easier to document too.
I'll see if i can make a PR for it tonight
@GregorySech I added a new parameter to LazyLoadScrollView
named isLoading
. If you set a boolean to that it should make it work as you expect. Update your pubspec.yaml
to use version 0.0.3
Thanks for raising this!
Hi, I've used this plugin inside of a StreamBuilder without issues however when I try to use it inside a custom StatefulWidget the onEndOfPage callback gets called more than once.
Here the example app,