ChatAnimatedList constructor
const
ChatAnimatedList({
- Key? key,
- required ChatItem itemBuilder,
- ScrollController? scrollController,
- bool reversed = false,
- Duration insertAnimationDuration = const Duration(milliseconds: 250),
- Duration removeAnimationDuration = const Duration(milliseconds: 250),
- MessageAnimationDurationResolver? insertAnimationDurationResolver,
- MessageAnimationDurationResolver? removeAnimationDurationResolver,
- Duration scrollToEndAnimationDuration = const Duration(milliseconds: 250),
- Duration scrollToBottomAppearanceDelay = const Duration(milliseconds: 250),
- double scrollToBottomAppearanceThreshold = 0,
- double? topPadding = 8,
- double? bottomPadding = 20,
- Widget? topSliver,
- Widget? bottomSliver,
- bool? handleSafeArea = true,
- ScrollViewKeyboardDismissBehavior? keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.onDrag,
- InitialScrollToEndMode? initialScrollToEndMode = InitialScrollToEndMode.jump,
- bool? shouldScrollToEndWhenSendingMessage = true,
- bool? shouldScrollToEndWhenAtBottom = true,
- PaginationCallback? onEndReached,
- String? scrollToBottomArrow,
- double? paginationThreshold = 0.01,
- MessagesGroupingMode? messagesGroupingMode,
- int? messageGroupingTimeoutInSeconds,
- 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,
});