'android SharedPreferences order/sort by field
i am retrieving all SharedPreferences inside my app like this:
getCollection() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
if (prefs.getInt("collectionCount") == null) {
clearCollection();
} else {
collectionCount = prefs.getInt("collectionCount")!;
url = prefs.getStringList("collectionUrl")!.reversed.toList();
method = prefs.getStringList("collectionMethod")!.reversed.toList();
headers = prefs.getStringList("collectionHeaders")!.reversed.toList();
body = prefs.getStringList("collectionBody")!.reversed.toList();
name = prefs.getStringList("collectionName")!.reversed.toList();
syntax = prefs.getStringList("collectionSyntax")!.reversed.toList();
}
}
Is there a way to order the output by the name (collectionName) field in alphabetic order?
Solution 1:[1]
Instead of using reversed try with sort function. Here some info about sort function (i think that language is dart): Sort a list of objects in Flutter (Dart) by property value
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Alvaro Martinez |