Chrysolites Tech Academy

Photo Social App with FlutterFlow and Supabase · Course book

Chapter 17: Post Details and Parameters

Pairs with Lesson 17: The Post Detail Page and Page Parameters

Tapping a thumbnail in a grid, whether on a profile, in search results or in the explore view, should open that post at full size with its caption, likes and comments. That screen is the post detail page, and building it introduces one of the most important ideas in app navigation: page parameters, the values one page hands to another when it opens it. This chapter designs the detail page, explains how to pass post data into it and the trade-offs of passing a whole row or just an id, worked out by hand, deals with the common bottom navigation bar problem on detail pages, makes the back navigation behave, and tests the result.

One page, any post

A photo app may hold thousands of posts, but it needs only one detail page. The page is a template: it shows whichever post it is given. That is what page parameters provide. The detail page declares a parameter, for example post of the type of a row from the posts-with-authors view, or postId of type integer or string, and every widget on the page reads from it: the image from the post's image address, the header from its username and avatar, the caption from its caption.

The layout reuses the post card component built for the feed, which already contains the header, image, action row and caption. Placing that component on the detail page and passing it the parameter means the detail view looks exactly like the feed, which users expect, and any change to the card appears in both places. Below the card, the detail page has room for extras the feed lacks, such as the full list of comments, added in later parts.

Where the user tapsNavigation actionParameter passed
A tile on a profile gridNavigate to the post detail pageThat tile's post
A search resultNavigate to the post detail pageThe result's post, or its id
An activity notification, laterNavigate to the post detail pageThe id of the post concerned
A shared link, laterOpen the app at the detail pageThe id, read from the link

Passing data: a whole row or an id

There are two ways to tell the detail page which post to show. Passing the whole row sends every field the page needs, so the page can draw immediately without asking the database anything. Passing just the id sends a tiny value, and the page then runs its own query to fetch the post.

Worked example. A row from the posts-with-authors view, with its image address, caption, username, avatar, counts and times, is about 400 bytes. Passing it means the detail page appears instantly, with no wait. Passing only the id, a UUID of 36 characters, means the page must fetch the row first, one round trip of perhaps 60 to 150 milliseconds on a phone network, during which a loading placeholder shows. However, the id stays correct if the post changes: if the author edits the caption a minute after the grid was loaded, a page given the old row shows the old caption, while a page that fetches by id shows the new one. And only the id can travel inside a shared link or a notification, because those are just short pieces of text.

A good compromise uses both. Pass the row when it is available, so the page draws instantly, and also refresh it in the background by id, so the counts and caption are current. Pages that can be opened from links or notifications should accept an id as their main parameter, because that is all those sources can provide.

Parameters can be marked required or optional. A required parameter forces every navigation action that opens the page to supply it, which catches mistakes in the editor before they reach users: you cannot accidentally open the detail page without saying which post. Optional parameters suit extras, such as a flag telling the page to scroll straight to the comments when it was opened from a comment notification. Giving parameters clear names, such as postId rather than p, makes every navigation action in the project easier to read.

A page given an id must also handle the case where the id refers to nothing: the post may have been deleted since the notification was sent, or a shared link may be mistyped. In that case the query returns no row, and the page should say "This post is no longer available" with a way back, rather than showing an empty frame or crashing. Thinking about the "not found" case for every page that fetches by id is a habit that prevents many confusing bugs.

Finally, the detail page is the natural place for actions that the feed keeps out of the way. A menu in the app bar can offer to share the post, copy a link to it, report it if it breaks the rules, and, when the viewer is the author, edit the caption or delete the post. Showing the author-only options requires comparing the post's user_id with the signed-in user's id, and the database policies must enforce the same rule, so that hiding a button is a convenience rather than the only protection.

Profile grid Search results Navigate to PostDetail parameter: post Post detail page post card component comments appear here later back returns to whichever page opened it
Figure 17.1 — Many grids, one detail page. Each tap passes its post as a parameter, and back returns to the page that opened the detail view.

The navigation bar on detail pages

A common surprise when adding a detail page is the bottom navigation bar. FlutterFlow shows the bar on pages that are part of it, and a detail page opened from a page inside the bar can end up showing the bar in an odd state, or the app can report an error because the detail page is not itself one of the bar's tabs. The cleanest design keeps the detail page out of the navigation bar entirely: it is a page pushed on top of the current tab, with its own app bar and back button, and it hides the bottom bar so that the photo has the full screen.

Whether the bar is hidden or kept is a design decision, and both exist in popular apps. Keeping it visible lets users jump to another tab from a post; hiding it focuses attention and gives more room. Either way, the choice should be consistent across all detail pages, such as posts, other users' profiles and chats, so the app behaves predictably.

Navigating back

The detail page needs a way back. An app bar with a back arrow, or a back icon in the top corner, runs a Navigate Back action, which returns to whichever page opened the detail page: the profile, the search results or the feed. Because the opening page is still in the navigation stack beneath, it reappears exactly as it was, with the same scroll position and search results, which is what users expect.

The phone's own back gesture and Android's back button do the same thing automatically for pushed pages. Problems arise only if navigation replaced the previous page instead of pushing on top of it; in that case back would leave the app or jump somewhere unexpected. For detail pages, push navigation is the right choice. Opening several detail pages in a row, such as a post, then its author's profile, then another post, simply stacks them, and back unwinds them one at a time in reverse order.

Some apps let users move between posts from the detail page, swiping to see the next post in the grid they came from. That requires passing the whole list and the starting position, rather than a single post, and is a natural improvement once the basic page works.

Testing

Test the detail page from every place that opens it: a profile tile, a search result, and later a notification. Check that the right post appears each time, with its image, author and caption, and that back returns to the correct page in the state it was left. Test a post with no caption, a very long caption and an author without a profile photo, so the layout copes with missing and oversized content. Finally, check how the page looks while data is loading and when the network fails, especially if it fetches by id, so that users never see an empty or broken screen.

Practice tasks

  1. Give one advantage of passing the whole row and one advantage of passing only the id to the detail page.
  2. A detail page fetches its post by id over a network with 120-millisecond round trips. How long must the placeholder show, at least?
  3. List the parameters you would give the detail page so it can be opened from a grid, a notification and a shared link.
  4. Explain why the detail page should be pushed on top of the current page rather than replacing it.
  5. Should the bottom navigation bar appear on the detail page? Argue for one choice.
  6. Describe three tests for the detail page with unusual post content.

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.