Photo Social App with FlutterFlow and Supabase · Course book
Chapter 26: Designing Chat
Private messaging turns a photo app into a place where people talk, not only post. Before any chat data exists, this part designs the two pages chat needs in FlutterFlow: a chat groups page listing a user's conversations, and a chat page showing the messages in one conversation with a box to write more. This chapter explains the layout of each, the conventions people expect from messaging apps, how message bubbles are sized and when to show time stamps, worked out by hand with a graph, and how the design prepares for the tables and actions built in the following parts.
The chat groups page
The chat groups page, often reached from a paper-plane or speech-bubble icon in the feed's top bar, lists every conversation the user belongs to. Each row shows the other person's avatar, or a group picture, their name in bold, a one-line preview of the latest message in grey, and the time of that message on the right. Unread conversations stand out with bold text or a coloured dot. The list is ordered by the time of the latest message, newest first, so active conversations stay at the top of the list.
A search box at the top filters conversations by name, and a button in the app bar starts a new chat, opening a list of people to message. A friendly, encouraging empty state, such as "No messages yet. Start a conversation with someone you follow", guides new users. Because this page will hold many rows, it uses a ListView built lazily, and each row is a component with parameters for the picture, name, preview, time and unread state. Previews should start with "You: " when the latest message was the user's own, a small cue that tells them at a glance whether they are waiting for a reply.
| Row element | Shows | Comes from, later |
|---|---|---|
| Avatar | The other member, or a group picture | The users table, through the chat's members |
| Name | The other member's name, or the group name | The users table or the chats table |
| Preview | The latest message, cut to one line | The newest row in the messages table |
| Time | "3m", "Yesterday" or a date | The latest message's created_at |
| Unread dot | Whether anything new has arrived | A last-read time compared with the latest message |
The chat page
Tapping a conversation opens the chat page. Its app bar shows the other person's avatar and name, which can be tapped to open their profile, and a back arrow to the list of conversations. The body is a list of messages, and the bottom holds the input bar: a text field that grows to a few lines, a button to attach a photo if desired, and a send button that is disabled while the field is empty.
Messages follow a convention every messaging app shares. The user's own messages sit on the right in coloured bubbles, usually the app's accent colour with white text; other people's messages sit on the left in light grey bubbles with dark text. That simple rule lets people read a conversation at a glance without names on every single message. In a group chat, the sender's small avatar and name appear beside the first of their consecutive messages.
The message list is usually reversed, so that it starts at the bottom with the newest message just above the input bar and older messages appear as the user scrolls up. That matches how people read chats and means the newest message is visible as soon as the page opens, without a scroll to the end. Older messages load in pages as the user scrolls upwards.
The input bar must stay visible while typing. When the keyboard opens, it takes roughly the lower 40 percent of the screen, and the input bar should rise with it while the message list shrinks and stays scrolled to the newest message. FlutterFlow pages adjust for the keyboard by default; placing the input bar at the bottom of a column whose list is Expanded keeps the arrangement right on every phone. Tapping the message list or dragging it down should dismiss the keyboard, so the user can read further back. The text field should grow from one line to perhaps five as a long message is written, then scroll internally, so the input never pushes the conversation off screen.
Long-pressing a message commonly offers a small menu: copy the text, reply to it, react with an emoji or, for one's own messages, delete it. These are natural extensions once messages are stored, and designing room for them now, for instance by making each bubble a component that can receive an action parameter, saves rework later.
Sizing bubbles and spacing time stamps
A message bubble wraps tightly around short messages and grows to a maximum width for long ones, so a single word does not stretch across the screen and long messages remain easy to read. A common limit is 75 percent of the screen width.
Showing the time on every message clutters the page. The usual rule groups messages: a centred time stamp, such as "Today 18:04", appears only when more than a set gap, often five minutes, has passed since the previous message. Consecutive messages from the same sender within that gap can also be drawn closer together, with only the last bubble in the run showing a tail or avatar.
Time stamps themselves follow a readable pattern: "18:04" for today, "Yesterday 21:30" for yesterday, the weekday for the past week and a short date such as "12 Nov" beyond that. The chat groups page uses an even shorter form, such as "3m", "2h" or "Mon", because space in each row is limited. Computing these from each message's stored time, in the viewer's own time zone, means two people in different countries each see times that make sense where they are.
Preparing for data
Designing both pages with placeholder conversations, a few short and long messages from both sides, reveals layout problems before any real data arrives: bubbles that do not wrap, previews that overflow the row, or an input bar hidden by the keyboard. The message bubble should be a component with parameters for the text, the time and whether the current user sent it; that one true-or-false parameter decides alignment and colour, so the whole conversation is drawn from a single design that is easy to restyle later.
The pages also reveal what the database must provide. The chat groups page needs to know which chats the user belongs to, who the other members are and the latest message in each. The chat page needs the messages for one chat in time order, each with its sender. The next parts create exactly those tables: chats and their members, then messages, followed by sending, displaying and, in a later extra part, real-time updates so that messages appear without refreshing.
Private messaging also needs safety in its design. People should be able to block someone from the chat page's menu, after which that person can no longer message them, and to report a conversation that is abusive. Some apps limit who can start a chat, for instance to people the user follows or to mutual followers, which greatly reduces unwanted messages. Accessibility matters as well: each bubble should be read by screen readers as "Maya, 18:04: Loved your Lisbon photo", the send button needs a label, and the colours of both kinds of bubble must contrast enough with their text, aiming for at least 4.5 to 1, so messages stay readable for everyone.
Practice tasks
- On a 414-point screen with bubbles limited to 70 percent and 14 points of padding each side, how wide is the text area?
- Using about 35 characters per line, 20-point lines and 20 points of padding, how tall is a bubble for a 150-character message?
- Messages arrive at 18:00, 18:02, 18:09, 18:10 and 18:30. With a five-minute rule, where do time stamps appear?
- Explain why the chat page's message list is reversed.
- List the parameters of the message bubble component and what each controls.
- What information must the database provide for each row of the chat groups page?
This course book is available to read online only at tech-academy.chrysolites.org.