Chrysolites Tech Academy

Photo Social App with FlutterFlow and Supabase · Course book

Chapter 11: The Feed from a Query

Pairs with Lesson 11: Querying and Displaying Posts

Posts can now be saved; the next step is showing them. A home feed needs to query the database for posts, newest first, and display each one with the post card designed earlier. This chapter explains how FlutterFlow does that: turning the post card into a component with parameters, attaching a Supabase query to a list so that it generates one component per row, passing each row's data into the component, ordering and limiting results, and testing that what appears matches the database. It also works out by hand how page size trades the speed of the first screen against the number of requests needed while scrolling.

Components with parameters

A component is a reusable piece of interface, designed once and placed wherever it is needed. The post card, with its header row, image, action icons and caption, is the perfect candidate: the home feed shows many of them, and the post detail page, search results and profile will reuse it. In FlutterFlow, a selection of widgets can be converted into a component, which then appears in the widget panel like any built-in widget.

To show different posts, a component declares parameters: named inputs with types, such as an image address, a caption, a username and a like count, or a single parameter holding a whole post row. Inside the component, each widget is bound to a parameter rather than to fixed placeholder content: the image widget shows the image address parameter, and the caption's rich text shows the username and caption parameters. When the component is placed on a page, the page provides the values.

ApproachParametersAdvantagesDrawbacks
Individual fieldsimageUrl, caption, username, likeCount and so onClear; the component works with data from anywhereMore parameters to wire up on each page
Whole rowOne parameter holding a posts rowOne binding per use; new columns are available automaticallyThe component depends on the table's structure

Either approach works; passing the whole row is quicker in FlutterFlow and is common when a component always displays data from one table, while individual fields keep the component more independent.

Components can also have their own component state, values that belong to one instance, such as whether a long caption is expanded or whether the heart has just been tapped. Each card in the feed keeps its own copy, so expanding one caption does not expand them all. Components can trigger actions too, and can expose callbacks, actions passed in by the page, so that a tap on the comment icon inside the card can open a comment sheet that the page controls. Keeping the card focused on display, and letting the page decide what happens on navigation, makes the same component useful on every screen.

Querying Supabase from a list

A ListView on the home page holds the feed. In FlutterFlow, a widget can have a backend query attached: choosing a Supabase query on the posts table, with conditions and ordering, makes the list fetch the matching rows when the page loads. Setting the list to generate children dynamically from the query result repeats a child, the post card component, once for every row, and each child can refer to its own row.

Two query settings matter immediately. Ordering by created_at descending puts the newest posts first, as users expect. Limiting the number of rows keeps the first load quick, and FlutterFlow's infinite-scroll option fetches further pages as the user nears the end of the list. A filter, such as only posts by people the user follows, can be added later.

Queries can run in two places. A backend query on a widget, as described here, fetches data when the widget appears and can refresh automatically, which suits lists and displays. A query rows action, run from a button or on page load, fetches data on demand and stores the result in state for later use, which suits cases where the data drives logic rather than a list, such as checking whether a username is taken. FlutterFlow also lets a query be set to refresh on every page visit or to be cached for a while; caching makes returning to the feed instant but may show slightly old content, so pull-to-refresh is a good companion.

Behind the scenes, each query is an ordinary request to Supabase's REST API, carrying the signed-in user's token. The database applies its row level security policies to that request, so the same query can return different rows for different users if the policies say so. That is what will later make features such as private accounts or blocked users work without changing the app's queries.

Supabase query table: postsorder: created_at desclimit: 20 per pagereturns rows ListView generate childrenfrom query resultone card per row PostCard(row 1)PostCard(row 2)PostCard(row 3) @maya · Sunset pier@leo · Coffee art@sam · City lights each card receives its own row as a parameter
Figure 11.1 — From query to feed. The list repeats the post card for every row the query returns, giving each card its own data.

Displaying the post data

Inside the generated list, each post card's parameters are set from the current row: the image address from image_url, the caption from caption and so on. The author's username and picture live in the users table, not the posts table, so a first version may show the user id or fetch the user separately; a later part creates a database view that joins posts with their authors so that one query returns everything the card needs.

Formatting turns raw values into friendly text. The created_at timestamp can be shown as a relative time such as "3h", the like count in compact form such as "1.2K", and a missing caption simply hidden rather than showing an empty line. FlutterFlow's conditional visibility settings make it easy to hide a widget when its value is empty.

Images load from the network, so the card should handle the moment before they arrive and the case where they fail. A grey placeholder of the right shape avoids the layout jumping as images appear, and an error image or icon is better than a blank space if an address is broken. Network images in FlutterFlow are cached on the device after the first load, so scrolling back up or reopening the app shows them instantly, which is another reason to keep image addresses stable once a post is created.

Page size, loading and requests

How many posts should each query fetch? Fetching more at once means fewer requests while scrolling, but a slower first screen and more data downloaded for posts the user may never see. A common compromise is a page of 10 to 25 posts.

Worked example. A user scrolls through 120 posts in a session. With pages of 10, the app makes ⌈120 / 10⌉ = 12 requests; with pages of 20, 6 requests; with pages of 60, 2 requests. The rows themselves are small, about 300 bytes each, so even 60 rows are only about 18 KB of data. The real cost of a large page is the images: if each card starts loading its image when created, 60 cards could start 60 image downloads at once. Lazy lists help here, because cards are only built, and their images only requested, as they approach the screen.
12642 10 per page203060 0612 requests
Figure 11.2 — Requests needed to scroll through 120 posts. Doubling the page size halves the requests, but makes the first screen wait for more data.

Pages should be fetched in a stable order, newest first by creation time, so that new posts arriving while the user scrolls do not shift later pages and cause posts to repeat. Pull-to-refresh at the top fetches the newest posts again, and an empty feed should invite the user to follow people or share a first post.

Testing what appears

Testing a query means comparing the screen with the database. Add a few posts with different captions, check in the Supabase table editor that they exist with the right times, then confirm that the feed shows them in the same order with the right images and captions. Delete one in the table editor and refresh the feed to see it disappear. If nothing appears, the usual culprits are a missing row level security policy for reading, which returns an empty list rather than an error, a schema that needs refreshing in FlutterFlow, or a parameter that is not bound inside the component.

A short recap closes the part: the post card is now a component, the feed queries Supabase and generates cards from real rows, and data is displayed with sensible formatting. The next parts add onboarding to collect each user's profile details, which the feed will then show alongside each post.

Practice tasks

  1. How many requests are needed to scroll through 75 posts with pages of 15? With pages of 25?
  2. Write the query settings, table, ordering and limit, for a feed showing the newest posts first.
  3. List the parameters you would give the post card component if you chose individual fields.
  4. The feed shows nothing, though the table has rows. Give three possible causes and how to check each.
  5. Why should a placeholder of the right shape be shown before an image loads?
  6. Explain why pages must be fetched in a stable order.

Install Chrysolites Tech Academy

Android / Chrome / Edge: open the browser menu and choose Install app or Add to Home screen.

iPhone / iPad (Safari): tap the Share button, then Add to Home Screen.