Combining Firebase collection filtering and Algolia search results on a single Details page

Working around a bug in the FlutterFlow driver.

https://community.flutterflow.io/integrations/post/algolia-search-returning-null-for-reference-fields-to-other-firebase-dpamirrDAj9SPBP   ( Algolia search returning null for reference fields to other firebase collections and Datetime objects ) 


 

This is happening because when you request an object from the search, it's not fully converted. Our sub collection (Seller) doesn't convert. Instead, you should take the ID you received from the search and use that ID to make a Firebase request. You should display the details from Firebase. You probably have two similar pages right now: one based on the search and the other based on Firebase. Today, you should have only one page, and it should work the same way. The page should receive an ID, request the object from Firebase, and display it.

So, there won't be any difference in the information displayed regardless of how you access the object, either through a search or via a filter. In both cases, you're obtaining the ID, and then you display the information on the detail page using that ID.

The request on the detail page is a separate request. I understand that Firebase allows you to fetch all objects at once, making it easy to navigate without the need for separate requests. However, in that case, you would require a second page, and you'd end up duplicating the same code. This approach doesn't work through Algolia because the collection driver doesn't display it. ( Bug https://community.flutterflow.io/integrations/post/algolia-search-returning-null-for-reference-fields-to-other-firebase-dpamirrDAj9SPBP )

 if it not fixed then Instead of structuring data by creating sub-collections in Algolia for specific trader information (e.g., trader_email, trader_phone, etc.), you could prefer to push the entire car object to an Algolia index via the API with trader infroamtion together. In this approach, trader-related information, such as trader_email, trader_phone, and others, would be included as fields within the car object itself, denormalisate redundancy. Algolia will handle queries related to this data efficiently and driver will convert basic data.

FlutterFlow example with Document as parameter

https://www.google.com/search?q=flutterflow+details+page+example&rlz=1C5CHFA_enBE963BE963&oq=flutterflow+details+page+example&gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIHCAEQIRigAdIBCTEwNjIyajBqNKgCALACAA&sourceid=chrome&ie=UTF-8#fpstate=ive&vld=cid:152309d0,vid:F_4O1uWm22g,st:0

Creating a FlutterFlow Details Page

In FlutterFlow, you can create a details page that displays information based on a unique ID passed from a previous page. Here's a step-by-step example of how to achieve this:

  1. Create a FlutterFlow Project: Start by creating a new FlutterFlow project or use an existing one.
  2. Create a Data Collection: You'll need a data collection (e.g., a database or API) that holds the information you want to display on the details page. For this example, let's assume you have a collection called "Items" with fields like "ID," "Name," and "Description."
  3. Design the List Page: Create a page that lists the items. You can use a ListView.builder or any other widget to display the list. Make sure each item in the list has a way to navigate to the details page.
  4. Pass the ID to Details Page: When the user taps on an item in the list, you need to pass the unique ID of that item to the details page. You can do this using the Flutter Navigator and the arguments parameter. Here's an example:
        
            Navigator.of(context).push(
              MaterialPageRoute(
                builder: (context) => DetailsPage(itemId: item.id),
              ),
            );
        
    
  1. Create the Details Page: Create a new page (e.g., DetailsPage) where you will display the details of the selected item. In the DetailsPage, define a constructor that accepts the itemId as an argument.
        
            class DetailsPage extends StatelessWidget {
              final String itemId;

              DetailsPage({required this.itemId});

              @override
              Widget build(BuildContext context) {
                // Fetch data based on itemId from your data collection.
                // You can use FutureBuilder, StreamBuilder, or any other method to fetch data.

                return Scaffold(
                  appBar: AppBar(
                    title: Text('Item Details'),
                  ),
                  body: Center(
                    child: FutureBuilder<Item>(
                      // Replace 'fetchItemById' with your data fetching function.
                      future: fetchItemById(itemId),
                      builder: (context, snapshot) {
                        if (snapshot.connectionState == ConnectionState.waiting) {
                          return CircularProgressIndicator();
                        } else if (snapshot.hasError) {
                          return Text('Error: ${snapshot.error}');
                        } else if (!snapshot.hasData) {
                          return Text('Item not found');
                        } else {
                          // Display item details using snapshot.data
                          final item = snapshot.data!;
                          return Column(
                            children: [
                              Text('Item Name: ${item.name}'),
                              Text('Item Description: ${item.description}'),
                              // Add more widgets to display other details as needed.
                            ],
                          );
                        }
                      },
                    ),
                  ),
                );
              }
            }
        
    
  1. Fetch Data in Details Page: In the DetailsPage, use a data fetching function (e.g., fetchItemById) to retrieve the item details based on the itemId. This function should query your data collection (database or API) and return the corresponding item data.
  2. Display Item Details: Use the snapshot.data in the FutureBuilder to display the item details on the DetailsPage. You can customize the UI to show various details such as name, description, images, etc., based on the retrieved data.

This example demonstrates how to create a FlutterFlow details page that receives an ID as a parameter, performs a data request based on that ID, and displays the details of the item on the page. Make sure to adapt it to your specific data source and design preferences.

Comments