File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
packages/stream_chat_persistence/lib/src Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -281,13 +281,15 @@ class StreamChatPersistenceClient extends ChatPersistenceClient {
281281 channelStates.sort (channelStateSort.compare);
282282 }
283283
284- final offset = paginationParams? .offset;
285- if (offset != null && offset > 0 && channelStates.isNotEmpty) {
286- channelStates.removeRange (0 , offset);
284+ // Apply offset
285+ if (paginationParams? .offset case final paginationOffset? ) {
286+ final clampedOffset = paginationOffset.clamp (0 , channelStates.length);
287+ channelStates.removeRange (0 , clampedOffset);
287288 }
288289
289- if (paginationParams? .limit != null ) {
290- return channelStates.take (paginationParams! .limit).toList ();
290+ // Apply limit
291+ if (paginationParams? .limit case final paginationLimit? ) {
292+ return channelStates.take (paginationLimit).toList ();
291293 }
292294
293295 return channelStates;
You can’t perform that action at this time.
0 commit comments