jumpFirstWhere method
bool
jumpFirstWhere(
- bool test(
- T item
- double alignment = 0.0,
- EdgeInsets padding = EdgeInsets.zero,
- BuildContext? sliverContext,
- bool isFixedHeight = false,
Jumps immediately to the first item matching the given test function.
The alignment determines where the item should be positioned in the viewport
(0.0 = top/left, 0.5 = center, 1.0 = bottom/right).
Returns true if a matching item was found and scrolled to, or false
if no match was found or no controller is attached.
Example:
cubit.jumpFirstWhere((item) => item.id == targetId);
cubit.jumpFirstWhere((item) => item.isHighlighted, alignment: 0.5);
Implementation
bool jumpFirstWhere(
bool Function(T item) test, {
double alignment = 0.0,
EdgeInsets padding = EdgeInsets.zero,
BuildContext? sliverContext,
bool isFixedHeight = false,
}) {
final items = currentItems;
final index = items.indexWhere(test);
if (index == -1) {
_logger.d('jumpFirstWhere: no matching item found');
return false;
}
return jumpToIndex(
index,
alignment: alignment,
padding: padding,
sliverContext: sliverContext,
isFixedHeight: isFixedHeight,
);
}