I am currently trying to pull data from a Cloud Firestore instance. No actual data is there yet just some sample testing data. The problem is I am coming across an error:
Another Exception was thrown: type 'int' is not a subset of type 'String'
To troubleshoot this I tried to use .toString() as shown below since the faulty data is an int but I am putting it into a Text() widget but it continues to throw the exception.
The code:
Widget buildItem(BuildContext context, DocumentSnapshot document) {
return ListTile(
title: Row(
children: [
Expanded(
child: Text(
document['Name'],
style: Theme.of(context).textTheme.headline1,
),
),
Container(
decoration: const BoxDecoration(
color: kBlueLight,
),
padding: const EdgeInsets.all(10),
child: Text(
document['Money'].toString(), //The exception is complaining about this line. I have tried with and without .toString()
style: Theme.of(context).textTheme.displaySmall,
),
)
],
),```
CodePudding user response:
Try to replace
document['Name']
to
document.get('Name')
and replace
document['Money'].toString()
to
document.get('Money').toString()