ChatAnimatedList constructor

const ChatAnimatedList({
  1. Key? key,
  2. required ChatItem itemBuilder,
  3. ScrollController? scrollController,
  4. bool reversed = false,
  5. Duration insertAnimationDuration = const Duration(milliseconds: 250),
  6. Duration removeAnimationDuration = const Duration(milliseconds: 250),
  7. MessageAnimationDurationResolver? insertAnimationDurationResolver,
  8. MessageAnimationDurationResolver? removeAnimationDurationResolver,
  9. Duration scrollToEndAnimationDuration = const Duration(milliseconds: 250),
  10. Duration scrollToBottomAppearanceDelay = const Duration(milliseconds: 250),
  11. double scrollToBottomAppearanceThreshold = 0,
  12. double? topPadding = 8,
  13. double? bottomPadding = 20,
  14. Widget? topSliver,
  15. Widget? bottomSliver,
  16. bool? handleSafeArea = true,
  17. ScrollViewKeyboardDismissBehavior? keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.onDrag,
  18. InitialScrollToEndMode? initialScrollToEndMode = InitialScrollToEndMode.jump,
  19. bool? shouldScrollToEndWhenSendingMessage = true,
  20. bool? shouldScrollToEndWhenAtBottom = true,
  21. PaginationCallback? onEndReached,
  22. String? scrollToBottomArrow,
  23. double? paginationThreshold = 0.01,
  24. MessagesGroupingMode? messagesGroupingMode,
  25. int? messageGroupingTimeoutInSeconds,
  26. ScrollPhysics? physics,
})

Creates an animated chat list.

Implementation

const ChatAnimatedList({
  super.key,
  required this.itemBuilder,
  this.scrollController,
  this.reversed = false,
  this.insertAnimationDuration = const Duration(milliseconds: 250),
  this.removeAnimationDuration = const Duration(milliseconds: 250),
  this.insertAnimationDurationResolver,
  this.removeAnimationDurationResolver,
  this.scrollToEndAnimationDuration = const Duration(milliseconds: 250),
  this.scrollToBottomAppearanceDelay = const Duration(milliseconds: 250),
  this.scrollToBottomAppearanceThreshold = 0,
  this.topPadding = 8,
  this.bottomPadding = 20,
  this.topSliver,
  this.bottomSliver,
  this.handleSafeArea = true,
  this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.onDrag,
  this.initialScrollToEndMode = InitialScrollToEndMode.jump,
  this.shouldScrollToEndWhenSendingMessage = true,
  this.shouldScrollToEndWhenAtBottom = true,
  this.onEndReached,
  this.scrollToBottomArrow,
  // Threshold for triggering pagination, represented as a value between 0 (top)
  // and 1 (bottom).
  //
  // IMPORTANT: This value defaults to a very small number (e.g., 0.01 or 1%)
  // for a critical reason. The scroll anchoring mechanism used to prevent
  // content jumps during pagination relies on accurately identifying the
  // *actual* topmost visible item *before* loading new content.
  //
  // A small threshold ensures that pagination is triggered only when the user
  // is very close to the top, making it highly likely that the scroll observer
  // correctly identifies the visually topmost item as the anchor.
  //
  // WARNING: Increasing this value significantly (e.g., to 0.2 or higher)
  // means pagination might trigger when items further down the viewport are
  // technically the "first visible" according to the observer. This will cause
  // the anchoring logic to select the wrong item, resulting in the list
  // jumping incorrectly after new items are loaded, potentially appearing to
  // scroll to a random position.
  //
  // Modify this value at your own risk. If you increase it and experience
  // unstable pagination jumps, revert to a smaller value like 0.01.
  this.paginationThreshold = 0.01,
  this.messagesGroupingMode,
  this.messageGroupingTimeoutInSeconds,
  this.physics,
});