scrollToMessage method

void scrollToMessage(
  1. String id, {
  2. Duration? scrollDuration,
  3. bool withHighlight = false,
  4. Duration? highlightDuration,
  5. AutoScrollPosition? preferPosition,
})

Scroll to the message with the specified id.

Implementation

void scrollToMessage(
  String id, {
  Duration? scrollDuration,
  bool withHighlight = false,
  Duration? highlightDuration,
  AutoScrollPosition? preferPosition,
}) async {
  await _scrollController.scrollToIndex(
    chatMessageAutoScrollIndexById[id]!,
    duration: scrollDuration ?? scrollAnimationDuration,
    preferPosition: preferPosition ?? AutoScrollPosition.middle,
  );
  if (withHighlight) {
    await _scrollController.highlight(
      chatMessageAutoScrollIndexById[id]!,
      highlightDuration: highlightDuration ?? const Duration(seconds: 3),
    );
  }
}