i want to receive data from a map i received from sharedpreference.
the Data looks like this:
{2022-04-08 15:49:41.864929: 1234567, 2022-04-08 15:49:55.392684: 1234567, 2022-04-08 15:50:17.168655: 1234567, 2022-04-08 15:50:39.263044: 1234567}
The date is they key, and the numbers the value. Now i need to display all 4 keys and the values in 4 listtiles. How is this possible? I am really new in flutter.
_saveData() async {
final prefs = await SharedPreferences.getInstance();
prefs.setString(DateTime.now().toString(), '1234567');
}
_clearData() async {
SharedPreferences preferences = await SharedPreferences.getInstance();
await preferences.clear();
print('Daten gelöscht');
}
_loadData() async {
final prefs = await SharedPreferences.getInstance();
final keys = prefs.getKeys();
final prefsMap = Map<String, dynamic>();
for(String key in keys) {
prefsMap[key] = prefs.get(key);
}
print(prefsMap);
}```
I included a rough example here.
You can check out the demo at https://dartpad.dev/087d5cfc1044c8ce742a0c5c7147940f