EdsonBueno / infinite_scroll_pagination

Flutter package to help you lazily load and display pages of items as the user scrolls down your screen.
https://pub.dev/packages/infinite_scroll_pagination
MIT License
632 stars 214 forks source link

the method fires after calling dispose, even if there is a "?" #152

Closed Kizat closed 2 years ago

Kizat commented 2 years ago

pagingController?.appendLastPage(products!.toList()); worked after calling dispose but ? didn't help and gave an error

_Exception (Exception: A PagingController was used after being disposed. Once you have called dispose() on a PagingController, it can no longer be used. If you’re using a Future, it probably completed after the disposal of the owning widget. Make sure dispose() has not been called yet before using the PagingController.)

clragon commented 2 years ago

the pagingController doesnt become null when it is disposed, so ? doesnt help here.

An easy way of removing this error is by checking the mounted property of your stateful widget.

or you can ignore the error;

Flutter for some reason didnt find it necessary to include any way of checking whether a changenotifier is disposed or not, so this entire error is just non-sensical, especially since they have a value to keep track of disposal, but its private.

EdsonBueno commented 2 years ago

Thanks for the amazing answer @clragon .