Firestore collections snapshot wont convert to csv

Viewed 35

I am trying to convert my firestore collection to csv format so i can email it in the code. I am doing it the following way:

_sendMail() async{
List tempList = await Firestore.instance
        .collection("transactions")
        .snapshots()
        .toList();
    print(tempList.toString());
    final res = const ListToCsvConverter().convert(tempList);
    print(res.toString());
}

The async function never prints the templist and res so im assuming it gets stuck at collection retrieving part. I know the firestore collection works because i retrieve documents from it in other parts of the app.

I am using the csv package for converting to csv format which requires a list: https://pub.dev/packages/csv

Does anyone know if im doing it wrong or theres another way to do it?

1 Answers

It's not stuck, even if it's offline, Firestore has offline mode and won't wait for anything. Probably tempList is empty, which is why you don't see anything printed.

Related