0

I am trying to make a simple notes app, in which I am using ListTiles to show all the notes saved. Is there a way I can sort this listview after it is built?

  • 1
    I am new to flutter. Please help –  Jul 24 '20 at 17:57
  • 1
    You are supposed to sort the list that the listview is holding. The listview has no idea what a list is – coroutineDispatcher Jul 24 '20 at 17:58
  • 1
    Ok. I figured a way to load the data in the list and sort that list. How do I close the question? Also us there a way to insert data in a sorted database in sqllite? –  Jul 24 '20 at 18:01
  • Does this answer your question? [how to sort list of songs from external storage alphabetically in flutter](https://stackoverflow.com/questions/54065146/how-to-sort-list-of-songs-from-external-storage-alphabetically-in-flutter) – omajid Jul 24 '20 at 19:36

1 Answers1

3

I don't think you can sort the ListView after creating it. The way to do it is to

  1. First sort your data.
  2. Then pass the sorted data to the ListView widget.

You can check out this doc for dart's sort method.

For your task, you have to create your own comparator to sort your data. And at the end just pass the data to the LlistView!

sphoenix
  • 3,327
  • 5
  • 22
  • 40