v0.5.0scroll_pos
为 ScrollController 提供一些额外功能,以定义项目相对于屏幕的位置。
74喜欢 20万近 30 天下载160Pub 分数
AndroidiOSWebmacOSWindowsLinux
为 ScrollController 提供一些额外功能,以定义项目相对于屏幕的位置。
{"sdk":"flutter"}{"sdk":"flutter"}^1.0.0以下为英文项目原文快照,最新内容请访问 GitHub。
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 !
// 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);
});
},
);
void scrollTop({bool? animate}) : Go to the first itemvoid scrollBottom({bool? animate}) : Go to the last itemvoid scrollToItem(int index, {bool? animate, bool center = false}) : Makes the item visible on the screen