Skip to content

Commit

Permalink
Fix throwing null errors after disposal in release mode (#305)
Browse files Browse the repository at this point in the history
fix #256
  • Loading branch information
cornetthomas committed Feb 19, 2024
1 parent e1a826d commit 0c4e3e5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/src/core/paging_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class PagingController<PageKeyType, ItemType>
/// Listeners can be removed with [removeStatusListener].
void addStatusListener(PagingStatusListener listener) {
assert(_debugAssertNotDisposed());
_statusListeners!.add(listener);
_statusListeners?.add(listener);
}

/// Stops calling the listener every time the status of the pagination
Expand All @@ -157,7 +157,7 @@ class PagingController<PageKeyType, ItemType>
/// Listeners can be added with [addStatusListener].
void removeStatusListener(PagingStatusListener listener) {
assert(_debugAssertNotDisposed());
_statusListeners!.remove(listener);
_statusListeners?.remove(listener);
}

/// Calls all the status listeners.
Expand All @@ -167,7 +167,7 @@ class PagingController<PageKeyType, ItemType>
void notifyStatusListeners(PagingStatus status) {
assert(_debugAssertNotDisposed());

if (_statusListeners!.isEmpty) {
if (_statusListeners?.isEmpty ?? true) {
return;
}

Expand All @@ -184,15 +184,15 @@ class PagingController<PageKeyType, ItemType>
/// Listeners can be removed with [removePageRequestListener].
void addPageRequestListener(PageRequestListener<PageKeyType> listener) {
assert(_debugAssertNotDisposed());
_pageRequestListeners!.add(listener);
_pageRequestListeners?.add(listener);
}

/// Stops calling the listener every time new items are needed.
///
/// Listeners can be added with [addPageRequestListener].
void removePageRequestListener(PageRequestListener<PageKeyType> listener) {
assert(_debugAssertNotDisposed());
_pageRequestListeners!.remove(listener);
_pageRequestListeners?.remove(listener);
}

/// Calls all the page request listeners.
Expand Down

0 comments on commit 0c4e3e5

Please sign in to comment.