Retrieving Data FlutterFlow collection and by Document Reference









A conversation has emerged regarding the topic of lists, data requests, and preferred documents and collections. As an illustration of the feasibility, I will create a small application and employ it as a test objective to showcase that it can be achieved.

Flutterflow has excellent documentation, so I will only put links here on pages where the information about the method can be found.

First, configure Fare Base and auth so that you can more easily reproduce and add permissions if necessary.

Full explanation can be found in document. Test it with run..

https://docs.flutterflow.io/data-and-backend/firebase/firebase-setup#3.-copy-project-id-to-flutterflow


If you could login then start with document and collection requests.

Then show data from favourites in the listview

https://docs.flutterflow.io/data-and-backend/showing-data-in-ui-elements#showing-field-data-in-listtile-listview








Then querying doc


https://docs.flutterflow.io/data-and-backend/firebase/firestore-database/retrieving-data#querying-a-document


Doc by ref





https://docs.flutterflow.io/data-and-backend/passing-data#passing-record-reference-to-other-page


In FlutterFlow, if you want to query a document based on a document reference and handle exceptions using try-catch blocks, you can follow these steps:

1. Import the necessary packages: Make sure you have the required packages imported in your Flutter project. Typically, you'll need the `cloud_firestore` package for Firestore database operations.


2. Query the document reference: Use the `FirebaseFirestore.instance.doc()` method to create a reference to the desired document. Then, use the `get()` method to fetch the document data.


3. Handle the document data: Once you have the `DocumentSnapshot`, you can access its data using the `data()` method. If the document exists, you can retrieve the data and perform necessary operations. If the document does not exist, you can handle that scenario appropriately.

4. Handle exceptions: Wrap the code that queries the document reference in a try-catch block. This way, if an exception occurs during the query process, it can be caught and handled accordingly. You can display an error message or redirect the user to a fallback screen within the catch block.

By following these steps, you can query a document based on a document reference and handle any exceptions that may occur during the process.




So in our case it is code when it loaded then Flutter will build UI.
We don't have to do anything because we have adjusted our strategy and we will no longer delete records but only change status.

The code is designed to load only when data is received from the server through a request.

While that's true, in our scenario, the condition should be different. Instead of the entire page waiting for loading, only a specific element, such as a column, should be targeted.

To begin with, we will focus on changing the status of cars, rather than deleting them from the database. Deleting cars would require a substantial amount of programming and deviate from standard FlutterFlow code.

In my role, I will modify the sync functionality to adjust the status of cars without performing deletions.


Comments