Skip to content

Zony-Zhao/scrollable_positioned_list

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

scrollable_positioned_list

A flutter list that allows scrolling to a specific item in the list.

Also allows determining what items are currently visible.

Usage

A ScrollablePositionedList works much like the builder version of ListView except that the list can be scrolled or jumped to a specific item.

Example

A ScrollablePositionedList can be created with:

final ItemScrollController itemScrollController = ItemScrollController();
final ItemPositionsListener itemPositionsListener = ItemPositionsListener.create();

ScrollablePositionedList.builder(
  itemCount: 500,
  itemBuilder: (context, index) => Text('Item $index'),
  itemScrollController: itemScrollController,
  itemPositionsListener: itemPositionsListener,
);

One then can scroll to a particular item with:

itemScrollController.scrollTo(
  index: 150,
  duration: Duration(seconds: 2),
  curve: Curves.easeInOutCubic);

or jump to a particular item with:

itemScrollController.jumpTo(index: 150);

One can monitor what items are visible on screen with:

itemPositionsListener.positions.addListener((positions) => ...);

A full example can be found in the example folder.


This is not an officially supported Google product.

About

forked from google/scrollable_positioned_list

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages