FLUTTER ECOSYSTEM

WinXaito/scroll_pos

Provides some additional functions to ScrollController to define item position relative to the screen.

scroll_pos project cover
Stars
11
Forks
0
Last push (UTC)
May 28, 2024
Project status
Active
Kevin Vuilleumier GitHub avatar
GITHUB User

Kevin Vuilleumier ↗

LanguagesC++DartCMakeHTMLCCSS

Packages published by this repository

Dependencies used

Dependency list 3 items
  • flutter{"sdk":"flutter"}
  • flutter_testDevelopment{"sdk":"flutter"}
  • flutter_lintsDevelopment^1.0.0

Original README

English project snapshot. Visit GitHub for the latest content.

Expand / collapse project README

Scroll Position

Provides some additional functions to ScrollController to define item position relative to the screen.

A live version is available here.

scrollpos_demo

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);
    });
  },
);

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