FirebaseExtended / firestoreodm-flutter

BSD 3-Clause "New" or "Revised" License
36 stars 11 forks source link

ConnectionState is stuck in waiting status if coming from a page which used the same QuerySnapshot #16

Open Badane opened 8 months ago

Badane commented 8 months ago

Expected Behavior

Hello, I connect to a same collection in different pages in my application. I use the FiresoreBuilder as so, in each page which need data from this "cellars" collection :

     FirestoreBuilder(
          ref: cellarsRef, 
          builder: (BuildContext context, AsyncSnapshot<CellarQuerySnapshot>snapshot, Widget? child) {
            if (snapshot.hasError) {
              print(snapshot.error.toString());
              return Center(child: Text('An error has occured!'));
            }
            if (snapshot.connectionState == ConnectionState.waiting) {
              return Center(
                child: CircularProgressIndicator(),
              );
            }

            CellarQuerySnapshot cellarSnapshot = snapshot.requireData;
            return Wrap(
              children: [
                for(int i=0;i<cellarSnapshot.docs.length;i++) ...{
 ...

My ""cellarsRef"" is declared in the model file and imported with the model in each page.

Actual Behavior

If I navigate to another page wich use the same FirestoreBuilder, the connectionState will be stuck with the waiting status. I have to navigate to a "clean" page, and come back to see my data correctly displayed. Do you have an idea how I can be sure that each connection is closed before I create another one ? Thank you

Specifications