How to implement a ListView with alphabet shown as sticky side headers, similarly to the Telegram application?
For example, while we look at the countries that begin with the letter "E", the letter "E" is not scrolling as long as there are countries that begin with the letter "F". Then the letter "E" is changed to the letter "F".
2
Answers
Here is a solution using Nested
ListViews
.Interesting points about the solution:
Persons
. You wouldn’t want to exclude all of Norway’s Øyvind, would you?SplayTreeMap
to keep the Map sorted.ScrollController
and thePersons
mapping, happening only whencontacts
is changed.Full source code
Solution with Sticky Side Header
You have a package for that! The flutter_sticky_header package.
Interesting points about the solution:
Persons
. You wouldn’t want to exclude all of Norway’s Øyvind, would you?SplayTreeMap
to keep the Map sorted.Persons
mapping, happening only whencontacts
is changed.Full source code