scrollToItem method

void scrollToItem(
  1. T item, {
  2. bool highlightItem = false,
})

Scrolls to item.

Requires the collection bloc to support BlocxCollectionScrollableMixin.

Implementation

void scrollToItem(T item, {bool highlightItem = false}) {
  if (!_bloc.isScrollable) {
    throw StateError(
      'scrollToIndex can only be used on a bloc that mixes in '
      'BlocxCollectionScrollableMixin<$T, $P>.',
    );
  }

  final scrollableBloc = _bloc as BlocxCollectionScrollableMixin<T, P>;
  scrollableBloc.add(
    BlocxCollectionEventScrollToItem<T>(
      item: item,
      highlightItem: highlightItem,
    ),
  );
}