Scroll to Message

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

@ -1320,6 +1320,7 @@ 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);
if (index >= 1) {
double contentSize = scrollController.position.viewportDimension + scrollController.position.maxScrollExtent; double contentSize = scrollController.position.viewportDimension + scrollController.position.maxScrollExtent;
double target = contentSize * index / userChatHistory.length; double target = contentSize * index / userChatHistory.length;
scrollController.position.animateTo( scrollController.position.animateTo(
@ -1327,14 +1328,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
duration: const Duration(seconds: 1), duration: const Duration(seconds: 1),
curve: Curves.easeInOut, 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