@@ -91,9 +91,20 @@ mixin _MessageSequence {
91
91
/// conceptually belongs in this message list.
92
92
/// That information is expressed in [fetched] and [haveOldest] .
93
93
///
94
+ /// See also [middleMessage] , an index which divides this list
95
+ /// into a top slice and a bottom slice.
96
+ ///
94
97
/// See also [contents] and [items] .
95
98
final List <Message > messages = [];
96
99
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
+
97
108
/// Whether [messages] and [items] represent the results of a fetch.
98
109
///
99
110
/// This allows the UI to distinguish "still working on fetching messages"
@@ -162,8 +173,11 @@ mixin _MessageSequence {
162
173
/// The indices 0 to before [middleItem] are the top slice of [items] ,
163
174
/// and the indices from [middleItem] to the end are the bottom slice.
164
175
///
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] .
167
181
int get middleItem {
168
182
switch (items.lastOrNull) {
169
183
case null :
0 commit comments