Photo Social App with FlutterFlow and Supabase · Course book
Chapter 3: Rows, Columns and the Post
Every screen in a Flutter app, and therefore every page built in FlutterFlow, is a tree of widgets: boxes inside boxes, each with a job. Learning to build a page means learning a small set of layout widgets and how they divide space, then applying a few design principles so that the result looks clean and balanced. This chapter covers those foundations as they are used to design the photo app's main pages: columns and rows and how their axes and alignment work, padding and spacing on a consistent grid, dividers, building a complete post card, styling mixed text with rich text, and adding the bottom navigation bar. The space calculations are worked out by hand so that layouts behave predictably on any phone.
Columns, rows and their axes
A Column stacks its children vertically, and a Row places them side by side. Almost every layout is a combination of the two. Each has a main axis, the direction it arranges children in, vertical for a column and horizontal for a row, and a cross axis at right angles to it. Two properties control placement along these axes.
| Property | Direction in a Column | Direction in a Row | Common values |
|---|---|---|---|
| Main axis alignment | Vertical | Horizontal | start, center, end, space between, space around, space evenly |
| Cross axis alignment | Horizontal | Vertical | start, center, end, stretch |
| Main axis size | Height used | Width used | max (fill the space) or min (fit the children) |
A post's header row is a typical example: a row with the author's avatar, the username and, at the far end, a menu icon. Setting the row's main axis alignment to space between pushes the first and last children to the edges, while cross axis alignment center lines them up vertically. When one child should take all remaining space, such as the username in that row, it is wrapped in an Expanded widget, or given a flex value, so it grows to fill the gap and long names are shortened with an ellipsis instead of overflowing.
Expanded children share space in proportion to their flex values. Two Expanded children with flex 1 and 2 divide the free space one third and two thirds; children without Expanded keep their natural size and are measured first, before any free space is shared.
Padding, spacing and the grid
Space between elements is what makes a design feel calm rather than cramped. Padding adds space inside a widget's edges; in FlutterFlow it can be set for all sides at once or for each side separately. Spacing between the children of a row or column can be set directly as a gap, or added with small spacer widgets. Consistency matters more than any particular value, which is why many designers use an 8-point grid: every margin, padding and gap is a multiple of 4 or 8, such as 4, 8, 12, 16 and 24.
A Divider is a thin horizontal line that separates groups of content, such as sections on a settings page or posts in a feed. Its thickness, colour and indents are adjustable; a light grey line of one point with space above and below reads as a gentle break rather than a hard border. Used sparingly, dividers and white space together organise a page without boxes everywhere.
Text follows the same principle of consistency. FlutterFlow's theme defines a small set of text styles, such as display, headline, title, body and label, each with a font, size, weight and colour. Choosing from these styles, rather than setting sizes by hand on each text widget, keeps the hierarchy clear: usernames in a bold title style, captions in the body style, time stamps in a small, muted label style. Changing a style in the theme then updates every page at once. Two fonts at most, often one for headings and one for body text, and a limited palette of colours from the theme, are usually enough for a polished app.
Layouts must also cope with screens of different sizes. Widths given as fixed numbers can overflow on small phones or look stretched on tablets, while widths expressed as a share of the available space, with Expanded children or percentage widths, adapt automatically. On wide screens, such as tablets or the web, constraining the feed to a maximum width, say 600 points, centred on the screen, keeps posts from becoming unreasonably large. FlutterFlow's preview can switch between device sizes, which makes it easy to check each page as you build it.
Building the post card
The post is the most important design in the app, repeated on every feed page. It is a column of four parts: a header row, the image, an action row and a caption area.
The image should fill the card's width and keep the photo's shape. Setting its width to the full available width and its height from an aspect ratio, such as 4:5, keeps every post consistent; the image's fit mode, usually cover, crops rather than stretches photos of other shapes. During design, a placeholder image from FlutterFlow's library or a solid colour stands in for real photos, which will come from the database later.
The action row holds the like, comment and share icons on the left and a bookmark icon on the right, separated by a Spacer or an Expanded empty box. Icons should be large enough to tap, around 24 to 28 points with generous padding. Turning the finished card into a component means it can be reused on the feed, the post detail page and anywhere else a post appears.
Rich text for captions
A caption usually begins with the author's username in bold, followed by the caption in regular weight, flowing together as one paragraph. A plain text widget can apply only one style, so FlutterFlow's Rich Text widget is used instead: it holds several spans, each with its own style, that wrap together like ordinary text. The first span is the username in bold; the second is a space and the caption in normal weight.
Rich text also suits other mixed styles: a muted grey "View all 24 comments" line, a time stamp in a smaller size, or a hashtag in the accent colour. Limiting the caption to two lines, with an ellipsis and a "more" link to expand it, keeps long captions from pushing the next post off screen.
The bottom navigation bar
The main pages, home, search, create, notifications or profile, are reached from a bottom navigation bar, which FlutterFlow can generate across all pages that are marked as part of the navigation bar. Each page in the bar gets an icon, optionally a label, and an order; selecting a tab switches pages while the bar stays in place. The bar's colours and the style of the selected icon come from the theme, and photo apps commonly hide the labels and use filled icons for the selected tab and outlined icons for the rest.
A few principles keep the bar effective: between three and five items, ordered by importance with the main feed first; icons that are instantly recognisable; and a central create button that stands out. The bar should only appear on top-level pages; detail pages such as a single post or a chat usually hide it, giving their content the full screen and making the back button the obvious way out.
With the post card and navigation in place, the main structure of the app is visible even before any data exists. The next parts design the remaining pages, the profile with its tab bar and grid, the forms for editing and posting, and the search page, using the same small set of widgets.
Practice tasks
- A row on a 375-point screen has 16 points of padding on each side, a 44-point avatar, two 8-point gaps and a 24-point icon. How wide is an Expanded username?
- Two Expanded children with flex 2 and 3 share 300 points. How wide is each?
- What is the height of a full-width 4:5 image on a 412-point screen?
- Sketch the widget tree for a comment row with an avatar, rich text and a small like icon.
- Explain the difference between main axis and cross axis alignment for a row.
- Why should the post card be made into a component, and where will it be reused?
This course book is available to read online only at tech-academy.chrysolites.org.