This package lets you generate lexo ranks in flutter. Lexo rank ordering of items in a list according to their alphabetical rank.
- We use lexo ranks whenever we have use case of rearranging list items
- instead of having integer based ranking we can have String and bucket based lexo ranks, so that rearranging list items is done in o(1) complexity. Drag and drop is a popular feature in applications. However, by implementing this functionality, you should be aware of some nuances: a large number of elements, recalculation of the positions every time and some additional logic if you have different sections in the list.
You can read more about why and how to use lexo ranks here:
- https://tmcalm.nl/blog/lexorank-jira-ranking-system-explained/
- https://medium.com/whisperarts/lexorank-what-are-they-and-how-to-use-them-for-efficient-list-sorting-a48fc4e7849f
-
Generate first lexo rank we use ->
LexoRank rank = LexoRank.middle()
-
Generate previous lexo rank ->
rank.genPrev()
-
Generate next rank ->
rank.genNext()
-
Generate Middle Lexo Rank ->
prevLexoRank.between(nextLexoRank)
-
Parse strings to make LexoRank objects Usecase -> For example you are storing lexo ranks in Database as String, and in order to generate new ranks, you will need LexoRank objects, the function
LexoRank.parse(str)
which accepts a string will return you aLexoRank
object kudos to @maelchiotti for this documentation suggestion
Please go to root -> example/lib/main.dart to look into comprehensive example.