scroll_pos

Creator: coderz1093

Last updated:

Add to Cart

Description:

scroll pos

Scroll Position #
Provides some additional functions to ScrollController
to define item position relative to the screen.
A live version is available here.


Note: this works on condition that all items have the same height !

Usage #
// Create a ScrollPosController (don't forget to set and update itemCount !)
final controller = ScrollPosController(itemCount: itemCount);

// Assign the controller to a scrollable item (like an ListView)
ListView(
controller: controller,
children: [
...
];
);

// Control the controller
TextButton(
child: Text('To item'),
onPressed: () {
setState(() {
controller.scrollToItem(index);
});
},
);
copied to clipboard
Main methods #

void scrollTop({bool? animate}) : Go to the first item
void scrollBottom({bool? animate}) : Go to the last item
void scrollToItem(int index, {bool? animate, bool center = false}) : Makes the item visible on the screen

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.