How to reverse listview in Flutter

Dev9977 picture Dev9977 · Sep 28, 2018 · Viewed 15.5k times · Source

I implemented a listview which get data from a json.

I followed this implementation.

How could i reverse the order of this listview? (The first element should became the last, ecc...).

Answer

chemamolins picture chemamolins · Sep 28, 2018

You should be able to reverse the list before feeding it to the ListView.

List<String> animals = ['cat', 'dog', 'duck'];
List<String> reversedAnimals = animals.reversed.toList();