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
612 stars 202 forks source link

[Crash] Null check operator used on a null value #256

Closed trulykasodiya-hub closed 5 months ago

trulykasodiya-hub commented 1 year ago

PagingController.notifyStatusListeners package:infinite_scroll_pagination/src/core/paging_controller.dart:170 Null check operator used on a null value

0 PagingController.notifyStatusListeners package:infinite_scroll_pagination/src/core/paging_controller.dart:170
1 PagingController.value= package:infinite_scroll_pagination/src/core/paging_controller.dart:94
2 PagingController.error= package:infinite_scroll_pagination/src/core/paging_controller.dart:69
3 _SalesOrdersBodyState._fetchPage package:mobile/View/Screen/Sales_Order/sales_orders.dart:76
cornetthomas commented 7 months ago
/// Calls all the status listeners.
  ///
  /// If listeners are added or removed during this function, the modifications
  /// will not change which listeners are called during this iteration.
  void notifyStatusListeners(PagingStatus status) {
    assert(_debugAssertNotDisposed());

    if (_statusListeners!.isEmpty) {
      return;
    }

    final localListeners = List<PagingStatusListener>.from(_statusListeners!);
    localListeners.forEach((listener) {
      if (_statusListeners!.contains(listener)) {
        listener(status);
      }
    }

Any reason we should expect _statusListeners to never be null? In case you dispose the paging_controller and a callback still happens this can be null.

It would be safer to use _statusListeners?without any downside here?

cornetthomas commented 7 months ago

I guess it is similar as in #246

cornetthomas commented 7 months ago

@EdsonBueno I created a PR for your review

ItsYasser commented 6 months ago

was this really fixed ? i'm still having the same issue in my crash analytics even thought i upgraded the package to the last version

acudworth commented 6 months ago

Would be good to get @cornetthomas's PR merged in and a fix out for this. Very much a live issue right now @EdsonBueno.

pixnbit commented 5 months ago

Is this library still maintained? The PR looks very straightforward

matmicro commented 5 months ago

Any progress on this fix ? Is there a chance to get this released ?