Skip to content

Commit 8f51995

Browse files
🐛 Fixed(#95): Pagination is not working properly. (#105)
1 parent 32d14ab commit 8f51995

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
##(Unreleased)
2+
3+
* **Feat**: [105](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/105) Allow user
4+
to get callback when image is picked so user can perform operation like crop. Allow user to pass
5+
configuration like height, width, image quality and preferredCameraDevice.
6+
* **Fix**: [95](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/95) Fix issue of
7+
chat is added to bottom while `loadMoreData` callback.
8+
19
## [1.3.0]
210

311
* **Feat**: [71](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/71) Added Callback

example/lib/main.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ class _ChatScreenState extends State<ChatScreen> {
7979
chatController: _chatController,
8080
onSendTap: _onSendTap,
8181
featureActiveConfig: const FeatureActiveConfig(
82-
lastSeenAgoBuilderVisibility: true,
83-
receiptsBuilderVisibility: true),
82+
lastSeenAgoBuilderVisibility: true,
83+
receiptsBuilderVisibility: true,
84+
),
8485
chatViewState: ChatViewState.hasMessages,
8586
chatViewStateConfig: ChatViewStateConfiguration(
8687
loadingWidgetConfig: ChatViewStateWidgetConfiguration(

lib/src/controller/chat_controller.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ class ChatController {
121121

122122
/// Function for loading data while pagination.
123123
void loadMoreData(List<Message> messageList) {
124-
initialMessageList.addAll(messageList);
124+
/// Here, we have passed 0 index as we need to add data before first data
125+
initialMessageList.insertAll(0, messageList);
125126
messageStreamController.sink.add(initialMessageList);
126127
}
127128

lib/src/widgets/chat_list_widget.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class ChatListWidget extends StatefulWidget {
114114

115115
class _ChatListWidgetState extends State<ChatListWidget>
116116
with SingleTickerProviderStateMixin {
117-
final ValueNotifier<bool> _isNextPageLoading = ValueNotifier(false);
117+
final ValueNotifier<bool> _isNextPageLoading = ValueNotifier<bool>(false);
118118
ValueNotifier<bool> showPopUp = ValueNotifier(false);
119119
final GlobalKey<ReactionPopupState> _reactionPopupKey = GlobalKey();
120120

@@ -241,7 +241,7 @@ class _ChatListWidgetState extends State<ChatListWidget>
241241
void _pagination() {
242242
if (widget.loadMoreData == null || widget.isLastPage == true) return;
243243
if ((scrollController.position.pixels ==
244-
scrollController.position.minScrollExtent) &&
244+
scrollController.position.maxScrollExtent) &&
245245
!_isNextPageLoading.value) {
246246
_isNextPageLoading.value = true;
247247
widget.loadMoreData!()

0 commit comments

Comments
 (0)