@@ -169,7 +169,7 @@ void main() {
169169 InfiniteList (
170170 itemCount: itemCount,
171171 onFetchData: emptyCallback,
172- separatorBuilder: (_) {
172+ separatorBuilder: (_, __ ) {
173173 separatorBuilderCalls++ ;
174174 return const Divider ();
175175 },
@@ -181,6 +181,28 @@ void main() {
181181 },
182182 );
183183
184+ testWidgets (
185+ 'forward the correct indexes to separatorBuilder' ,
186+ (tester) async {
187+ const itemCount = 20 ;
188+ final indexes = < int > [];
189+
190+ await tester.pumpApp (
191+ InfiniteList (
192+ itemCount: itemCount,
193+ onFetchData: emptyCallback,
194+ separatorBuilder: (_, index) {
195+ indexes.add (index);
196+ return const Divider ();
197+ },
198+ itemBuilder: (_, i) => Text ('$i ' ),
199+ ),
200+ );
201+
202+ expect (indexes, equals (List .generate (itemCount - 1 , (index) => index)));
203+ },
204+ );
205+
184206 group ('with an empty set of items' , () {
185207 testWidgets (
186208 'renders no list items by default' ,
@@ -380,7 +402,7 @@ void main() {
380402 dimension: 40 ,
381403 child: ColoredBox (color: colors[i % colors.length]),
382404 ),
383- separatorBuilder: (_) => const SizedBox .square (
405+ separatorBuilder: (_, __ ) => const SizedBox .square (
384406 dimension: 10 ,
385407 child: ColoredBox (color: Colors .pink),
386408 ),
@@ -422,7 +444,7 @@ void main() {
422444 dimension: 40 ,
423445 child: ColoredBox (color: colors[i % colors.length]),
424446 ),
425- separatorBuilder: (_) => const SizedBox .square (
447+ separatorBuilder: (_, __ ) => const SizedBox .square (
426448 dimension: 10 ,
427449 child: ColoredBox (color: Colors .pink),
428450 ),
0 commit comments