Ad

Flutter: Stuck Getting Collection From Firestore

DocumentReference ref = FirebaseFirestore.instance
        .collection('invoices')
        .doc(authService.getUser().uid); // or non existing ID

    // here works if I return {}

    final doc = await ref.get();
    final data = doc.data();

When trying locally either with simulator or with real device (connected by usb) works fine, but in released app, the await takes for ever.

This was also working ok before updating to flutter 2.8 but now it fails only on Android

Ad

Answer

Reposting my comments as they seemed to have helped:

You should handle possible exceptions. The get method returns an instance of Future, which may complete with an error. When awaiting it, it may throw.

Ad
source: stackoverflow.com
Ad