@@ -580,7 +580,7 @@ class _MessageListState extends State<MessageList> with PerAccountStoreAwareStat
580
580
}
581
581
582
582
Widget _buildListView (BuildContext context) {
583
- final length = model! .items.length;
583
+ final numItems = model! .items.length;
584
584
const centerSliverKey = ValueKey ('center sliver' );
585
585
final zulipLocalizations = ZulipLocalizations .of (context);
586
586
@@ -603,22 +603,24 @@ class _MessageListState extends State<MessageList> with PerAccountStoreAwareStat
603
603
// have state that needs to be preserved have not been given keys
604
604
// and will not trigger this callback.
605
605
findChildIndexCallback: (Key key) {
606
- final valueKey = key as ValueKey <int >;
607
- final index = model! .findItemWithMessageId (valueKey.value);
608
- if (index == - 1 ) return null ;
609
- return length - 1 - (index - 3 );
606
+ final messageId = (key as ValueKey <int >).value;
607
+ final itemIndex = model! .findItemWithMessageId (messageId);
608
+ if (itemIndex == - 1 ) return null ;
609
+ final childIndex = numItems - 1 - (itemIndex - 3 );
610
+ return childIndex;
610
611
},
611
- childCount: length + 3 ,
612
- (context, i ) {
612
+ childCount: numItems + 3 ,
613
+ (context, childIndex ) {
613
614
// To reinforce that the end of the feed has been reached:
614
615
// https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/flutter.3A.20Mark-as-read/near/1680603
615
- if (i == 0 ) return const SizedBox (height: 36 );
616
+ if (childIndex == 0 ) return const SizedBox (height: 36 );
616
617
617
- if (i == 1 ) return MarkAsReadWidget (narrow: widget.narrow);
618
+ if (childIndex == 1 ) return MarkAsReadWidget (narrow: widget.narrow);
618
619
619
- if (i == 2 ) return TypingStatusWidget (narrow: widget.narrow);
620
+ if (childIndex == 2 ) return TypingStatusWidget (narrow: widget.narrow);
620
621
621
- final data = model! .items[length - 1 - (i - 3 )];
622
+ final itemIndex = numItems - 1 - (childIndex - 3 );
623
+ final data = model! .items[itemIndex];
622
624
return _buildItem (zulipLocalizations, data);
623
625
}));
624
626
@@ -641,7 +643,7 @@ class _MessageListState extends State<MessageList> with PerAccountStoreAwareStat
641
643
},
642
644
643
645
controller: scrollController,
644
- semanticChildCount: length , // TODO(#537): what's the right value for this?
646
+ semanticChildCount: numItems , // TODO(#537): what's the right value for this?
645
647
center: centerSliverKey,
646
648
paintOrder: SliverPaintOrder .firstIsTop,
647
649
0 commit comments