fix(ui): fix positioned list view null check

This commit is contained in:
Salvatore Giordano
2021-10-29 12:22:05 +02:00
parent c8c3296e3e
commit 26393402d8
2 changed files with 8 additions and 4 deletions
@@ -399,8 +399,11 @@ class _MessageListViewState extends State<MessageListView> {
final first = _itemPositionListener.itemPositions.value.first;
final diff = newMessagesListLength - _messageListLength!;
if (diff > 0) {
initialIndex = first.index + diff;
initialAlignment = first.itemLeadingEdge;
if (messages[0].user?.id !=
streamChannel!.channel.client.state.currentUser?.id) {
initialIndex = first.index + diff;
initialAlignment = first.itemLeadingEdge;
}
}
}
}
@@ -1259,8 +1262,9 @@ class _MessageListViewState extends State<MessageListView> {
event.message!.user!.id ==
streamChannel!.channel.client.state.currentUser!.id) {
WidgetsBinding.instance!.addPostFrameCallback((_) {
_scrollController?.jumpTo(
_scrollController?.scrollTo(
index: 0,
duration: const Duration(seconds: 1),
);
});
}