scrollFirstWhere method
Future<bool>
scrollFirstWhere(
- bool test(
- T item
- bool animate = true,
- Duration duration = const Duration(milliseconds: 300),
- Curve curve = Curves.easeInOut,
- double alignment = 0.0,
- EdgeInsets padding = EdgeInsets.zero,
- BuildContext? sliverContext,
- bool isFixedHeight = false,
Scrolls to the first item matching test, using animation if animate is true.
This is a convenience method that calls either animateFirstWhere or jumpFirstWhere
based on the animate parameter.
Example:
await cubit.scrollFirstWhere((item) => item.id == targetId, animate: true);
cubit.scrollFirstWhere((item) => item.isNew, animate: false);
Implementation
Future<bool> scrollFirstWhere(
bool Function(T item) test, {
bool animate = true,
Duration duration = const Duration(milliseconds: 300),
Curve curve = Curves.easeInOut,
double alignment = 0.0,
EdgeInsets padding = EdgeInsets.zero,
BuildContext? sliverContext,
bool isFixedHeight = false,
}) async {
if (animate) {
return animateFirstWhere(
test,
duration: duration,
curve: curve,
alignment: alignment,
padding: padding,
sliverContext: sliverContext,
isFixedHeight: isFixedHeight,
);
} else {
return jumpFirstWhere(
test,
alignment: alignment,
padding: padding,
sliverContext: sliverContext,
isFixedHeight: isFixedHeight,
);
}
}