Scroll to Message

merge-requests/116/head
Aamir Muhammad 3 years ago
parent 5eec9dc07b
commit dd6b0c0902

@ -1320,21 +1320,15 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
void scrollToMsg(SingleUserChatModel data) { void scrollToMsg(SingleUserChatModel data) {
if (data.userChatReplyResponse != null && data.userChatReplyResponse!.userChatHistoryId != null) { if (data.userChatReplyResponse != null && data.userChatReplyResponse!.userChatHistoryId != null) {
int index = userChatHistory.indexWhere((SingleUserChatModel element) => element.userChatHistoryId == data.userChatReplyResponse!.userChatHistoryId); int index = userChatHistory.indexWhere((SingleUserChatModel element) => element.userChatHistoryId == data.userChatReplyResponse!.userChatHistoryId);
double contentSize = scrollController.position.viewportDimension + scrollController.position.maxScrollExtent; if (index >= 1) {
double target = contentSize * index / userChatHistory.length; double contentSize = scrollController.position.viewportDimension + scrollController.position.maxScrollExtent;
scrollController.position.animateTo( double target = contentSize * index / userChatHistory.length;
target, scrollController.position.animateTo(
duration: const Duration(seconds: 1), target,
curve: Curves.easeInOut, duration: const Duration(seconds: 1),
); curve: Curves.easeInOut,
);
// scrollController.scrollTo(index: 150, duration: Duration(seconds: 1)); }
// scrollController.animateTo(offset, duration: duration, curve: curve);
} }
// scrollController.animateTo(
// scrollController.position.maxScrollExtent,
// duration: const Duration(milliseconds: 100),
// curve: Curves.easeOut,
// );
} }
} }

Loading…
Cancel
Save