From b2eb51317f3abc2b18bd4655359ac788a385c85b Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Tue, 17 Aug 2021 16:17:19 +0530 Subject: [PATCH] refactor(ui): early return `Offstage` in case index is null. Signed-off-by: xsahil03x --- .../stream_chat_flutter/lib/src/message_list_view.dart | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/message_list_view.dart b/packages/stream_chat_flutter/lib/src/message_list_view.dart index 8d83ab9d..cd9c4b45 100644 --- a/packages/stream_chat_flutter/lib/src/message_list_view.dart +++ b/packages/stream_chat_flutter/lib/src/message_list_view.dart @@ -674,10 +674,9 @@ class _MessageListViewState extends State { index = _getBottomElementIndex(values); } - if (index == null || index <= 2 || index >= itemCount - 3) { - if (index == null) { - return const Offstage(); - } + if (index == null) return const Offstage(); + + if (index <= 2 || index >= itemCount - 3) { if (widget.reverse) { index = itemCount - 4; } else {