Photo Social App with FlutterFlow and Supabase · Course book
Chapter 25: Profiles
Profiles are where people present themselves and look each other up. With posts, likes, comments and follows in place, the photo app can now show complete profiles: the viewer's own, with an option to edit it, and other people's, with a follow button. This chapter builds both from one design, connects the header and grid to real data, creates the edit profile page that updates the user's name, username, bio and photo, explains why profile photos should be resized and given new file names when changed, worked out by hand with a graph, and covers the debugging and testing that tie it all together.
One design, two kinds of profile
A profile page shows a header and a grid. The header holds the profile photo, the display name and username, the bio and three statistics: posts, followers and following. The grid shows the user's posts as thumbnails, newest first, each opening the post detail page. What differs between the viewer's own profile and someone else's is mainly the button and a few options.
| Element | Own profile | Another user's profile |
|---|---|---|
| How it is opened | The profile tab in the navigation bar | Tapping a username or avatar anywhere |
| Which user it shows | The signed-in user | The user passed as a page parameter |
| Main button | Edit profile | Follow, Following or Follow back |
| Menu | Settings, log out | Share profile, report, block |
| Back navigation | None; it is a top-level tab | Back to the page that opened it |
Two approaches work. One page can serve both, taking an optional user parameter and comparing it with the signed-in user's id to decide which button and menu to show. Or two pages can share the same header and grid components, one fixed to the signed-in user and one taking a parameter. FlutterFlow makes the second approach simple and keeps each page's logic easy to read, while the shared components keep the design identical.
Data comes from two queries. The header reads the user's row, including the stored follower and following counts maintained by triggers, and a count of their posts. The grid queries the posts view filtered by the user's id, ordered newest first, loading more as the viewer scrolls. Empty states matter: a new user's own profile should invite them to share a first photo, while another user's empty profile can simply say "No posts yet".
The post count in the header can come from a count query on the posts table, from a view that adds the count to each user, or from a stored column kept by a trigger like the like and follow counts. A view is a good middle ground for an app of this size, because posts are created far less often than they are viewed and the count is exact. Whichever method is chosen, all three numbers should be formatted the same way and tappable: posts scrolls to the grid, while followers and following open lists of people built from the follow table, each with its own follow button.
Profiles opened by tapping a name should load quickly, even on a slow connection. Passing the user's row from the screen that opened the profile, where it is already known from a post or comment view, lets the header appear at once with the name and photo, while the statistics and grid load in the background. A shimmering placeholder for the grid, the same shape as the thumbnails, makes the wait feel shorter and avoids the page jumping as posts arrive.
The edit profile page
Tapping "Edit profile" opens a form with the current photo and a "Change photo" link, followed by fields for the display name, username and bio. Each field's initial value is set from the user's current row, so they change only what they want. Validation follows the rules from onboarding: the username must be unique, of an allowed length and made of allowed characters, and the bio is limited, for example to 150 characters with a counter.
Saving runs an Update Row action on the users table, filtered to the signed-in user's id, with the new values. The row level security policy allows users to update only their own row, so even a modified app cannot edit someone else's profile. A database unique constraint on the username remains the final guard if two people pick the same name at the same moment. After saving, the app updates the copy of the profile held in app state, so the new name and photo appear immediately on every screen, and returns to the profile.
A few details make editing pleasant. The save button is disabled until something has actually changed, and shows a loading state while saving. Leaving with unsaved changes asks for confirmation. And a changed username takes effect everywhere at once, because posts and comments store the user's id, not their name, and look the name up through views; nothing has to be rewritten.
Profile photos: resize and rename
Choosing a new photo opens the image picker with a square crop, uploads the result to the avatars bucket and saves its address on the user's row. Two practices make this efficient and reliable.
The first is resizing. Profile photos appear small, typically 32 to 96 points across, perhaps 288 pixels at most on a high-density screen, so there is no reason to store a full-resolution photo. FlutterFlow's upload action can set a maximum width and height.
The second practice is renaming. Images are cached by phones and networks using their address, which is what makes them load instantly the second time. If a new photo is saved at the same address as the old one, many devices keep showing the cached old picture. Saving each new photo under a new name, for example the user's id followed by a timestamp, and updating the address on the user's row, means every device sees the new photo as soon as it reloads the profile. The old file can then be deleted from the bucket so storage does not fill with abandoned pictures.
Users who never upload a photo still need something in the avatar's place. A neutral placeholder, such as a grey circle with a person icon or the user's initials on a coloured background, keeps every row and header looking complete. Generating the colour from the user's id, so it stays the same everywhere, helps people recognise each other even without photos. The app should treat an empty avatar address as "show the placeholder", rather than trying to load a missing image and displaying a broken-image icon.
Debugging and testing
Profiles bring together data from several tables, so debugging often means checking each source in turn. If another user's profile shows your own posts, the grid's filter is using the signed-in user's id instead of the page parameter. If the statistics show zero, the header may be reading the counts from the wrong row or the schema may need refreshing after the count columns were added. If a saved edit does not appear, the app state copy of the profile was not updated, or the update policy blocked the change; the Supabase table editor shows which. If a new avatar does not appear, the old address is being reused and served from cache.
A thorough test covers both kinds of profile. On your own profile, edit each field, change the photo, try a taken username and an over-long bio, and check that the new details appear in the feed and comments. With a second account, open your profile from a post and a comment, follow and unfollow, and check the counts and grid. Finally, check the empty states and the back navigation from another user's profile. The next parts build the chat feature, starting with its pages.
Practice tasks
- What percentage of a 4,032-pixel square photo's pixels remain at 320 × 320?
- A comment section shows 25 avatars. How much do they download at 35 KB each and at 2.5 MB each?
- Explain why a new profile photo should be saved under a new file name.
- Write the filter for the Update Row action that saves the user's profile.
- Another user's profile shows the viewer's posts. What is the likely cause?
- Why does changing a username not require updating any posts or comments?
This course book is available to read online only at tech-academy.chrysolites.org.