scrollToUserMessage method
void
scrollToUserMessage(
- String messageId
)
Implementation
void scrollToUserMessage(String messageId) async {
pendingScrollAlignUserMessageId.value = messageId;
update();
scrollToBottomChat(withAnimation: true);
await Future.delayed(const Duration(milliseconds: 250));
final BuildContext? anchorContext =
scrollAlignSentUserBubbleKey.currentContext;
if (anchorContext == null) return;
Scrollable.ensureVisible(
// ignore: use_build_context_synchronously
anchorContext,
alignment: 0.0,
duration: const Duration(milliseconds: 320),
curve: Curves.easeOutCubic,
alignmentPolicy: ScrollPositionAlignmentPolicy.explicit,
);
WidgetsBinding.instance.addPostFrameCallback((_) {
pendingScrollAlignUserMessageId.value = null;
update();
});
}