@@ -91,9 +91,20 @@ mixin _MessageSequence {
9191 /// conceptually belongs in this message list.
9292 /// That information is expressed in [fetched] and [haveOldest] .
9393 ///
94+ /// See also [middleMessage] , an index which divides this list
95+ /// into a top slice and a bottom slice.
96+ ///
9497 /// See also [contents] and [items] .
9598 final List <Message > messages = [];
9699
100+ /// An index into [messages] dividing it into a top slice and a bottom slice.
101+ ///
102+ /// The indices 0 to before [middleMessage] are the top slice of [messages] ,
103+ /// and the indices from [middleMessage] to the end are the bottom slice.
104+ ///
105+ /// The corresponding item index is [middleItem] .
106+ int get middleMessage => messages.isEmpty ? 0 : messages.length - 1 ;
107+
97108 /// Whether [messages] and [items] represent the results of a fetch.
98109 ///
99110 /// This allows the UI to distinguish "still working on fetching messages"
@@ -162,8 +173,11 @@ mixin _MessageSequence {
162173 /// The indices 0 to before [middleItem] are the top slice of [items] ,
163174 /// and the indices from [middleItem] to the end are the bottom slice.
164175 ///
165- /// If the bottom slice is not empty,
166- /// then its first item is a [MessageListMessageItem] .
176+ /// The top and bottom slices of [items] correspond to
177+ /// the top and bottom slices of [messages] respectively.
178+ /// Either the bottom slices of both [items] and [messages] are empty,
179+ /// or the first item in the bottom slice of [items] is a [MessageListMessageItem]
180+ /// for the first message in the bottom slice of [messages] .
167181 int get middleItem {
168182 switch (items.lastOrNull) {
169183 case null :
0 commit comments