From 717d989954b21cffb03ef7de46c915f36b624faf Mon Sep 17 00:00:00 2001 From: Tommy Chow Date: Wed, 27 Jul 2022 16:17:15 -0400 Subject: [PATCH] Convert chat to from builder to `ListView` (#154) Since widgets are built bottom up in the chat, most of the benefits of the `ListView.builder` are likely null. --- lib/screens/channel/chat/chat.dart | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/screens/channel/chat/chat.dart b/lib/screens/channel/chat/chat.dart index 91d9542e..35aa32a2 100644 --- a/lib/screens/channel/chat/chat.dart +++ b/lib/screens/channel/chat/chat.dart @@ -35,16 +35,17 @@ class Chat extends StatelessWidget { style: DefaultTextStyle.of(context).style.copyWith(fontSize: chatStore.settings.fontSize), child: Observer( builder: (context) { - return ListView.builder( + return ListView( reverse: true, padding: EdgeInsets.zero, addAutomaticKeepAlives: false, controller: chatStore.scrollController, - itemCount: chatStore.renderMessages.length, - itemBuilder: (context, index) => ChatMessage( - ircMessage: chatStore.renderMessages.reversed.toList()[index], - chatStore: chatStore, - ), + children: chatStore.renderMessages.reversed + .map((e) => ChatMessage( + ircMessage: e, + chatStore: chatStore, + )) + .toList(), ); }, ),