Chrysolites Tech Academy

Photo Social App with FlutterFlow and Supabase · Course book

Chapter 13: Saving the Profile

Pairs with Lesson 13: Finishing Onboarding with Supabase

The onboarding screens designed in the previous part look right but do nothing yet. This chapter makes them work: sending new users to onboarding after sign-up, turning the repeated close row into a reusable component, collecting a username, a photo and a bio across the three steps, creating a user data table in Supabase to hold that profile, saving it when onboarding finishes, and adding a way to log out. It explains how each piece connects to the database, how to check that a username is free, how many usernames a set of rules allows, worked out by hand with a graph, and how to test the flow from a brand-new account.

Sending new users to onboarding

After a successful sign-up, the app should take the user to onboarding rather than straight to the feed. The simplest way is to add a navigation action after the Create Account action on the sign-up page, pointing to the onboarding page. Because sign-up is the only route into a brand-new account, this covers the common case. For robustness, the app can also check at sign-in whether the user has a completed profile and send them to onboarding if not, which handles users who closed the app halfway through.

Navigation here should replace the current page rather than push a new one on top, so that the phone's back gesture cannot return the user to the sign-up form after their account exists. FlutterFlow's navigation actions offer this as an option, and the same applies when onboarding finishes and the app moves to the home feed. Clearing the navigation history at that point means the back gesture on the feed exits the app, as users expect, instead of reopening onboarding.

Abstracting the close row

Each onboarding step has the same top row: a back or close icon on the left and the progress indicator. Building that row three times invites inconsistencies, so it becomes a component. The component takes parameters for the current step and the total number of steps, which drive the progress bar, and an action parameter, a callback that the page supplies, for what happens when the icon is tapped: going back one step on steps two and three, or cancelling on step one.

This is a small example of an important habit. Whenever the same arrangement of widgets appears more than once, turning it into a component means one place to change it and one behaviour to test. The skill is choosing parameters that make the component flexible without making it complicated: here, two numbers and one action are enough.

Action parameters deserve a closer look, because they unlock a lot of reuse. A component that contains a button does not need to know what the button should do on every page; it simply runs whatever action the page passed in. The same close-row component can therefore go back a step inside the PageView on one page, pop a page from the navigation stack on another, or show a confirmation dialog on a third. FlutterFlow lets the action parameter receive values from the component, too, so a reusable rating component could report which star was tapped and let each page decide what to do with it.

Collecting each step's input

Because the steps live inside one PageView on one page, their values are kept in page state: a text value for the username, an image address for the photo and a text value for the bio. Each step's input updates its page state variable, and the "Next" button checks its step before moving on.

  • Username: validate the length and characters, check that the name is not already taken, then store it and animate to the next step.
  • Photo: an upload action sends the chosen image to the profile photos bucket and stores the returned address; "Skip for now" moves on without one, leaving a default avatar in its place.
  • Bio: a multi-line field with a counter; "Finish" saves everything to the database.

Checking that a username is free requires a query: a Query Rows action on the user data table, filtered by username, returning whether any row matches. If one does, the step shows "That username is taken" and stays put. Comparing usernames case-insensitively, by storing them in lower case, prevents near-duplicates such as "Maya" and "maya". The database's unique constraint on the username column is the final safeguard, because two people could pass the check at the same moment and only the database can decide which insert wins.

Worked example. Suppose usernames may use the 26 lower-case letters, the 10 digits, the dot and the underscore: 38 characters. There are 383 = 54,872 possible three-character usernames, 386 ≈ 3.0 billion six-character ones and 3810 ≈ 6.3 quadrillion ten-character ones. Short names run out quickly in a popular app, which is why most apps set a minimum length of three or more, and why suggesting variations, such as adding a number, helps users find a free name. Rules such as "no dot at the start or end" reduce these counts slightly but keep names readable and easy to type.
55 thousand3 billion6 quadrillion 1041091014 3456810 username length (characters)possible usernames (log scale)
Figure 13.1 — Each extra character multiplies the possible usernames by 38, but popular short names are still taken first.

The user data table and saving the profile

Supabase Authentication stores accounts in its own schema, so the app's profile information needs its own user data table in the public schema. Its key column, id, is a UUID that equals the authenticated user's id, which is both the primary key and the link to the account. Other columns hold the username, the display name, the bio, the profile photo address, the creation time and, usefully, a flag recording that onboarding is complete.

ColumnTypeRuleSet by
iduuidPrimary key; equals the account idThe authenticated user's id
usernametextUnique, required, lower caseStep one
avatar_urltextOptionalStep two, or left empty
biotextOptional, at most 150 charactersStep three, or left empty
onboardedboolDefault falseSet true when Finish succeeds
created_attimestamptzDefault now()The database

When the user taps "Finish", an Insert Row action creates the row with the page state values, or, if a row was already created at sign-up, an Update Row action fills it in. Row level security policies must allow a user to insert and update only the row whose id equals auth.uid(). After the change succeeds, the app replaces the onboarding page with the home feed. After adding the table in Supabase, remember to refresh the schema in FlutterFlow so that the new table appears in the actions.

Once the profile exists, many pages need it: the feed shows the user's avatar, the profile page shows the bio, and new posts are attributed to the username. Loading the row once after sign-in and keeping it in app state avoids querying for it on every page. When the user edits their profile later, the app updates both the database row and the app state copy, so every screen shows the change at once. If the app state is persisted on the device, it should be refreshed from the database at each launch, so that edits made on another phone are picked up.

Logging out and testing

Every app needs a way to sign out, which is also essential for testing with several accounts. A log-out button, placed on the profile page or in a settings menu, runs FlutterFlow's Log Out action, which clears the session on the device; the app then returns to the login page automatically, because the user is no longer authenticated. Any app state holding the previous user's data, such as their profile or liked posts, should be cleared at the same time, so the next person to sign in on the device never sees it.

Testing should start from a brand-new email address: sign up, confirm the email, complete each onboarding step, check the new row in the Supabase table editor, and arrive at the feed. Then test the variations: a username that is already taken, skipping the photo and bio, going back a step and changing the username, logging out and signing in again to check that onboarding is not shown twice. Each of these is a path a real user will take sooner or later. Finally, look at the new rows in the Supabase table editor to confirm that the usernames are stored in lower case, the onboarded flag is set and skipped fields are empty rather than filled with placeholder text.

Practice tasks

  1. How many four-character usernames can be made from 38 characters? How many from 36, if the dot and underscore are not allowed?
  2. Write the steps the "Next" button on the username step takes, in order.
  3. Explain why the username check needs both a query and a unique constraint.
  4. What parameters does the close-row component take, and why is an action parameter useful?
  5. Write the update policy for the user data table in words.
  6. List four test cases for the onboarding flow and the expected result of each.

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.