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) {
if (data.userChatReplyResponse != null && data.userChatReplyResponse!.userChatHistoryId != null) {
int index = userChatHistory.indexWhere((SingleUserChatModel element) => element.userChatHistoryId == data.userChatReplyResponse!.userChatHistoryId);
double contentSize = scrollController.position.viewportDimension + scrollController.position.maxScrollExtent;
double target = contentSize * index / userChatHistory.length;
scrollController.position.animateTo(
target,
duration: const Duration(seconds: 1),
curve: Curves.easeInOut,
);
// scrollController.scrollTo(index: 150, duration: Duration(seconds: 1));
// scrollController.animateTo(offset, duration: duration, curve: curve);
if (index >= 1) {
double contentSize = scrollController.position.viewportDimension + scrollController.position.maxScrollExtent;
double target = contentSize * index / userChatHistory.length;
scrollController.position.animateTo(
target,
duration: const Duration(seconds: 1),
curve: Curves.easeInOut,
);
}
}
// scrollController.animateTo(
// scrollController.position.maxScrollExtent,
// duration: const Duration(milliseconds: 100),
// curve: Curves.easeOut,
// );
}
}

Loading…
Cancel
Save