ListView
populated from snapshot values, values are inside a Text.
The data is a timestamp in Firestore looking like this:
Currently they are generated like:
Added toDate()
Text(
'Date: ${snapshot.data!.docs[index].get('usoOn').toDate()}',
style: Theme.of(context).textTheme.headline4,
),
and used to look like this:
Had to remove toDate() because of an error NoSuchMethodError timestamp has no instance method to date. Similar to the one below.
Trying to change the format to look like this, it works with errores, both in the console and if you scroll below the ListView you get a big red message.
Most of the answers around that I found are related to using a String or a single value, not a populated ListView taking data from a snapshot.
Thank you for any help with this, still green on Flutter.
2
Answers
Changed to use FirestoreListView, it has better way to change the data type. Also some of the errors related to class int are because some of the data was wrong. Some was manually added during testing and had numerical instead of timestamp.
you can use this extension, add it some global scope (outside your class) :
and use it like this example:
in your example you can use it like this: