case PagingStatus.ongoing:
child = widget.loadingListingBuilder(
context,
// We must create this closure to close over the [itemList]
// value. That way, we are safe if [itemList] value changes
// while Flutter rebuilds the widget (due to animations, for
// example.)
(context, index) => _buildListItemWidget(
context,
index,
itemList!,
),
_itemCount,
_newPageProgressIndicatorBuilder,
);
break;
(and then similar cases for the other PagingStatus values).
The problem with this is that if you do something like the following
... and if newList is shorter than the old itemList, then you get an exception when the builder tries to access an index that is out of range. For example, I get an index out of range exception at this line in paged_layout_builder.dart:
final item = itemList[index];
The reason is that the old the itemList was captured in the closure, but the new item count is obtained from the new list.
So actually this builder pattern breaks for the opposite of the intended reason.
paged_layout_builder.dart
includes this code:(and then similar cases for the other
PagingStatus
values).The problem with this is that if you do something like the following
... and if
newList
is shorter than the olditemList
, then you get an exception when the builder tries to access an index that is out of range. For example, I get an index out of range exception at this line inpaged_layout_builder.dart
:The reason is that the old the
itemList
was captured in the closure, but the new item count is obtained from the new list.So actually this builder pattern breaks for the opposite of the intended reason.