Photo Social App with FlutterFlow and Supabase · Course book
Chapter 4: Tabs and Grids
The profile page is the second most important screen in a photo app. It has a header with the user's picture, name, statistics and bio, then a set of tabs, such as the user's own posts and posts they are tagged in, and beneath them a grid of square thumbnails that fills the rest of the screen and scrolls. This chapter builds that page in FlutterFlow and, in doing so, introduces two of its most useful layout widgets: the tab bar, which switches between views of related content, and the grid view, which arranges items in rows and columns. It explains how each is configured, how the grid's size depends on the number of posts, worked out by hand with a graph, and how to keep long grids smooth.
Creating the page and its header
A new page in FlutterFlow starts as an empty scaffold: a page with an optional app bar and a body. For a profile, the app bar can show the username, with a menu icon on the right for settings. The body is a column whose first child is the header, itself a column of a few parts.
- A row with the circular profile picture on the left and, to its right, three statistics, posts, followers and following, each a small column with a bold number above a label.
- The display name in bold and a short bio, which may wrap onto several lines.
- A full-width button, "Edit profile" on your own page, or "Follow" on someone else's.
The circular picture is a CircleImage widget, or an image with fully rounded corners and a fit of cover, sized around 80 to 96 points. The three statistics share the remaining width equally: placing each inside an Expanded widget with the same flex divides the space into three equal columns whatever the screen width. Centring each number and label within its column gives the familiar balanced look of social profiles, and tapping a statistic can later open the matching list.
The tab bar widget
A tab bar shows a row of tabs and, below it, the content for the selected tab, switching when the user taps a tab or swipes sideways. In FlutterFlow, the TabBar widget contains a list of tabs, each with an icon or label, and a matching page of content for each. A profile typically has two tabs: a grid icon for the user's posts and a person-in-a-square icon for posts they are tagged in, or saved posts on your own profile.
| Setting | What it controls | Typical choice for a profile |
|---|---|---|
| Tabs | The number of tabs and their icons or labels | Two tabs with icons only |
| Indicator | The line under the selected tab: colour, thickness and width | A thin dark line the width of the tab |
| Selected and unselected colours | How the active tab stands out | Dark for selected, grey for the others |
| Initial index | Which tab is shown first | 0, the posts tab |
| Swipe between tabs | Whether content can be swiped sideways | On, matching user expectations |
A tab bar has to know how tall its content area is. Inside a scrolling page, an unbounded height causes a layout error, so the content area is either given a fixed or Expanded height, filling the space below the header, or the whole page is built so that the header scrolls away and the tab bar sticks to the top, a more advanced pattern. For a first version, placing the tab bar inside an Expanded widget so that it takes the rest of the screen, with the grid scrolling inside it, is the simplest approach and works well.
The reason lies in how Flutter lays out widgets. A parent tells each child the largest and smallest sizes it may take, its constraints, and the child chooses a size within them. A scrolling column offers its children unlimited height, because it can scroll as far as needed. A tab bar's content area, or a grid that wants to fill "all the remaining space", cannot choose a size from unlimited height, so Flutter reports an error. Wrapping such a child in Expanded, inside a non-scrolling column, gives it a definite height: whatever is left after the header. Understanding this one rule, that scrollable areas need bounded space, explains most layout errors beginners meet in FlutterFlow.
Tabs that show only icons need accessible labels, so screen readers can announce "Posts" and "Tagged" rather than "button". FlutterFlow lets you set a semantic label on widgets for this purpose. It is also good practice to keep the selected tab when the user leaves the page and returns, so they do not lose their place.
The grid view widget
A GridView arranges its children in a grid that scrolls along one axis. Its key settings are the number of columns, the cross axis count; the spacing between columns and between rows; and the child aspect ratio, the width of each cell divided by its height, which is 1 for squares. For a profile, three columns with a spacing of 1 or 2 points and square cells give the classic photo-grid look. During design, placeholder images fill the cells; later, the grid is generated from the user's posts in the database.
Keeping grids smooth
A grid of a handful of placeholder images is easy for any phone, but a real profile may hold hundreds of posts. GridView builds its cells lazily: only the cells near the visible area are created, and those that scroll far away are discarded, so memory use stays roughly constant however long the grid is. That only works if the grid knows it is scrollable and is not forced to lay out every child at once, which is another reason to give it a bounded height or let it be the scrolling element of the page.
The images matter even more than the widget. Each thumbnail is only about 129 points across, perhaps 390 pixels on a high-density screen, so loading full-size photos for the grid wastes bandwidth and memory. Storing a smaller thumbnail for each post, or using an image service that resizes on request, lets the grid load quickly. Caching images, which FlutterFlow's image widgets do for network images, means scrolling back up shows them instantly.
Finally, tapping a cell should open that post. Each cell is wrapped in an action that navigates to the post detail page, passing the post's id as a parameter, a pattern built properly once posts come from the database. Designing the interaction now, even with placeholders, helps confirm the page's flow. Adding pull-to-refresh to the grid, so that new posts appear when the user drags down, completes the familiar behaviour of a profile page.
Polishing the profile layout
Small details make the page feel finished. The statistics should use compact numbers, such as 1.2K, so they fit at any size. The bio should respect line breaks and links. The edit button and the tab bar each need clear separation from the header, with consistent spacing from the 8-point grid. An empty state for a profile with no posts, a camera icon and "No posts yet", replaces a blank grid. And the same page design can serve both your own profile and other people's, with the button and a few options changing depending on whose profile it is, a decision that will be driven by the user's id once data is connected.
The next parts continue designing the remaining pages: forms with text fields for editing a profile and writing captions, the search page with its grid of results and a tabbed accounts view, and the pages for creating a post with the camera and gallery.
Practice tasks
- How many rows does a three-column grid need for 22 posts, and how tall is it with 128.7-point cells and 2-point spacing?
- On a 414-point screen with 1-point spacing and three columns, how wide is each square cell?
- A grid uses four columns and an aspect ratio of 0.8. On a 390-point screen with 2-point spacing, how wide and tall is each cell?
- Explain why a tab bar inside a scrolling page needs a bounded height.
- Why should the profile grid load thumbnails rather than full-size images?
- List the settings you would choose for a two-tab profile tab bar, and why.
This course book is available to read online only at tech-academy.chrysolites.org.