Skip to content

Commit 2cbb71d

Browse files
committed
msglist: Opt out of adding AutomaticKeepAlive widgets to the tree
Without these, it'll be more efficient to walk the element tree to find which messages are in the viewport. For mark-read-on-scroll, coming up.
1 parent a3313ec commit 2cbb71d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/widgets/message_list.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,10 @@ class _MessageListState extends State<MessageList> with PerAccountStoreAwareStat
666666
final topSliver = SliverStickyHeaderList(
667667
headerPlacement: HeaderPlacement.scrollingStart,
668668
delegate: SliverChildBuilderDelegate(
669+
// None of the children ever need to keep themselves alive;
670+
// opt out of adding AutomaticKeepAlive widgets that we don't need.
671+
addAutomaticKeepAlives: false,
672+
669673
// To preserve state across rebuilds for individual [MessageItem]
670674
// widgets as the size of [MessageListView.items] changes we need
671675
// to match old widgets by their key to their new position in
@@ -706,6 +710,10 @@ class _MessageListState extends State<MessageList> with PerAccountStoreAwareStat
706710
key: centerSliverKey,
707711
headerPlacement: HeaderPlacement.scrollingStart,
708712
delegate: SliverChildBuilderDelegate(
713+
// None of the children ever need to keep themselves alive;
714+
// opt out of adding AutomaticKeepAlive widgets that we don't need.
715+
addAutomaticKeepAlives: false,
716+
709717
// To preserve state across rebuilds for individual [MessageItem]
710718
// widgets as the size of [MessageListView.items] changes we need
711719
// to match old widgets by their key to their new position in

0 commit comments

Comments
 (0)