From cd06c42967d44ab677dfadbc09c4a5b7dc75ae7d Mon Sep 17 00:00:00 2001 From: riccardocucia Date: Mon, 14 Jul 2025 12:31:34 +0200 Subject: [PATCH] Fixed pagination --- lib/src/class/supabase_chat_controller.dart | 2 +- lib/src/class/supabase_chat_core.dart | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/class/supabase_chat_controller.dart b/lib/src/class/supabase_chat_controller.dart index f182b3d..9c21029 100644 --- a/lib/src/class/supabase_chat_controller.dart +++ b/lib/src/class/supabase_chat_controller.dart @@ -73,7 +73,7 @@ class SupabaseChatController { .select() .eq('roomId', int.parse(_room.id)) .order('createdAt', ascending: false) - .range(pageSize * _currentPage, (_currentPage * pageSize) + pageSize); + .range(pageSize * _currentPage, (_currentPage * pageSize) + pageSize - 1); void _onData( List> newData, diff --git a/lib/src/class/supabase_chat_core.dart b/lib/src/class/supabase_chat_core.dart index eea714c..a214a45 100644 --- a/lib/src/class/supabase_chat_core.dart +++ b/lib/src/class/supabase_chat_core.dart @@ -356,7 +356,7 @@ class SupabaseChatCore { : table.select(); var query = queryUnlimited.order('updatedAt', ascending: false); if (offset != null && limit != null) { - query = query.range(offset, offset + limit); + query = query.range(offset, offset + limit - 1); } else if (limit != null) { query = query.limit(limit); } @@ -574,7 +574,7 @@ class SupabaseChatCore { .order('firstName', ascending: true) .order('lastName', ascending: true); if (offset != null && limit != null) { - query = query.range(offset, offset + limit); + query = query.range(offset, offset + limit - 1); } else if (limit != null) { query = query.limit(limit); }