Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ListView scroll to selected item

Tags:

android

I have a ListView with an edit text and a button below it. When I click on a listView item the keyboard appears and push up the edit text and the button. I want the list to scroll to the selected item. Any idea? Thanks

like image 348
Anita Avatar asked Aug 17 '10 13:08

Anita


People also ask

How do I scroll to a specific item in ListView flutter?

A scroll controller creates a [ScrollPosition] to manage the state-specific to an individual [Scrollable] widget. To use a custom [ScrollPosition], subclass [ScrollController] and override [createScrollPosition]. A [ScrollController] is a [Listenable].

How do you scroll to a position in flutter?

All you have to do is set Global Keys for your widgets and call Scrollable. ensureVisible on the key of your widget you want to scroll to. For this to work your ListView should be a finite List of objects. If you are using ListView.

How do you control scroll in flutter?

If you want to use this controller function, you can add a ScrollNotification and keep calling it over and over again when the scroll ends, until the stop button is pressed.


1 Answers

You can use ListView's setSelection(int position) method to scroll to a row.

like image 156
androidworkz Avatar answered Sep 17 '22 16:09

androidworkz