fix(ui): add initialIndex and alignment to didUpdateWidget in scrollable list
This commit is contained in:
@@ -353,20 +353,6 @@ class _MessageListViewState extends State<MessageListView> {
|
||||
MessageListController get _messageListController =>
|
||||
widget.messageListController ?? _defaultController;
|
||||
|
||||
@override
|
||||
void didUpdateWidget(MessageListView oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (widget.initialScrollIndex != oldWidget.initialScrollIndex ||
|
||||
widget.initialAlignment != oldWidget.initialAlignment) {
|
||||
initialIndex = _initialIndex;
|
||||
initialAlignment = _initialAlignment;
|
||||
_scrollController?.jumpTo(
|
||||
index: initialIndex,
|
||||
alignment: initialAlignment,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => MessageListCore(
|
||||
paginationLimit: widget.paginationLimit,
|
||||
@@ -1255,14 +1241,12 @@ class _MessageListViewState extends State<MessageListView> {
|
||||
initialIndex = _initialIndex;
|
||||
initialAlignment = _initialAlignment;
|
||||
|
||||
WidgetsBinding.instance!.addPostFrameCallback((timeStamp) {
|
||||
if (_scrollController?.isAttached == true) {
|
||||
_scrollController?.jumpTo(
|
||||
index: initialIndex,
|
||||
alignment: initialAlignment,
|
||||
);
|
||||
}
|
||||
});
|
||||
if (_scrollController?.isAttached == true) {
|
||||
_scrollController?.jumpTo(
|
||||
index: initialIndex,
|
||||
alignment: initialAlignment,
|
||||
);
|
||||
}
|
||||
|
||||
_messageNewListener =
|
||||
streamChannel!.channel.on(EventType.messageNew).listen((event) {
|
||||
|
||||
+8
@@ -325,6 +325,14 @@ class _ScrollablePositionedListState extends State<ScrollablePositionedList>
|
||||
secondary.target = widget.itemCount - 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (widget.initialScrollIndex != oldWidget.initialScrollIndex ||
|
||||
widget.initialAlignment != oldWidget.initialAlignment) {
|
||||
_jumpTo(
|
||||
index: widget.initialScrollIndex,
|
||||
alignment: widget.initialAlignment,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user