Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Flutter cancelOnError = false doesn't work

I have a Firestore listener and when I induce an error by changing the security rules I get a permission-denied error printed out by onError, however I stop receiving any snapshot updates even though cancelOnError is set to false and I reverted the security rules. How to fix?

query
      .snapshots(includeMetadataChanges: true)
      .listen(
        (snapshot) {
          //stops being called after error occurs
        },
        onError: (error) {
          //print error
        },
        cancelOnError: false,
      )

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The cancelOnError property determines whether the client cancels the listener when an error occurs.

In this case though, it is the server that cancels the operation when an error occurs. There is no way to prevent this from happening, as this type of error typically indicates a programming mistake. You will have to fix the root cause, and re-attach the listener.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading