Photo Social App with FlutterFlow and Supabase · Course book
Chapter 5: Text Fields and Forms
Apps are not only for looking; people type into them constantly: a name and bio when editing a profile, a caption when posting, a search term, a comment, a message. Text fields are how a FlutterFlow app collects that input, and designing them well affects how pleasant the whole app feels. This chapter builds the input pages of the photo app, such as the edit profile page, and explains single-line and multi-line text fields, how their appearance and keyboard are configured, how their values are read by actions, how to validate input with helpful messages, and how to size a multi-line field by hand so that it shows exactly the right number of lines.
Building an input page
The edit profile page is a good example of a form. At the top sits the current profile picture with a "Change photo" link beneath it. Below come the fields: name, username and bio, each with a label. A save button, often placed in the app bar as a "Done" action or at the bottom of the page, writes the changes, and a cancel or back button discards them. The fields are arranged in a column with consistent spacing, and the whole page sits inside a scrollable area so that the save button and lower fields remain reachable when the keyboard is open.
Laying out a form clearly matters more than decorating it. Group related fields, put the most important first, and label every field. A label above the field, or one that floats up when the user starts typing, stays visible while typing; placeholder text inside the field alone disappears as soon as typing begins, so it should give an example or hint rather than replace the label. Fields should be wide enough to show typical input in full, and tall enough, at least 44 points, to tap easily.
Configuring text fields
FlutterFlow's TextField widget has many settings, and a handful matter for almost every field.
| Setting | Purpose | Example |
|---|---|---|
| Label and hint text | Tell the user what to enter | Label "Username", hint "letters, numbers and dots" |
| Keyboard type | Show the most useful keyboard | Email keyboard for email, number pad for codes |
| Capitalisation | Control automatic capitals | Words for names, none for usernames and emails |
| Obscure text | Hide what is typed | On for passwords |
| Max length | Limit characters and show a counter | 30 for usernames, 150 for a bio |
| Initial value | Prefill with existing data | The user's current name when editing |
| Input decoration | Borders, fill colour, focused and error styles | Light grey fill, accent border when focused |
The keyboard type is easy to overlook and makes a big difference on phones: an email field should show the @ key, a username field should not capitalise the first letter or autocorrect, and a code field should show a number pad. The text input action, the label on the keyboard's return key, can be set to "next" so that pressing it moves to the following field, and "done" on the last field, so users can move through the form without tapping each box.
Prefilling fields with existing data is essential on edit pages. When the edit profile page opens, each field's initial value is set from the current user's record, so the user changes only what they want. The values typed are available to actions as the field's current state, which the save button's action reads and writes to the database.
Multi-line text fields
A bio, a caption or a comment can run to several lines, so it needs a multi-line text field. In FlutterFlow, increasing the field's maximum number of lines, or leaving it unlimited, lets text wrap and the field grow; setting a minimum number of lines gives it a sensible starting height so the user can see that longer text is expected. Above the maximum, the field scrolls internally rather than pushing the rest of the page down indefinitely.
On the caption field of the new-post page, a larger limit, perhaps 2,200 characters, allows longer stories, but the field itself can stay a few lines tall, scrolling as the user writes. For comments and chat, a field that starts at one line and grows to four or five as the user types keeps the input bar compact until it is needed. Emoji and line breaks should be allowed in captions and comments, since people use them freely, but counted carefully: some emoji are made of several characters internally, so a counter may jump by more than one when one is added.
Validation and helpful errors
Validation checks input before it is saved. FlutterFlow can mark fields as required, set minimum and maximum lengths and apply patterns, such as allowing only letters, numbers, dots and underscores in a username. Wrapping the fields in a Form widget and running a Validate Form action before saving shows each field's error message beneath it and stops the save if any rule fails.
Good error messages say what is wrong and how to fix it: "Username can use letters, numbers, dots and underscores" is far more helpful than "Invalid input". Show errors next to the field that caused them, and only after the user has tried to submit or left the field, not while they are halfway through typing. Some checks need the server: whether a username is already taken can only be known by querying the users table, and the database's unique constraint is the final guard if two people choose the same name at once.
Trimming spaces from the start and end of input before saving avoids subtle problems such as a username with a trailing space that looks identical to another. Emails can be converted to lower case. These small clean-ups belong in the save action, just before the update.
The save action itself follows a pattern used throughout the app. First validate the form; if it fails, stop. Then show a loading state on the button, so the user knows something is happening and cannot tap twice. Then run the database update with the cleaned values. If it succeeds, show a brief confirmation, such as a snack bar saying "Profile updated", and navigate back; if it fails, keep the user on the page with their input intact and explain what went wrong, so nothing they typed is lost. FlutterFlow's action editor supports this with conditional branches that check whether the previous action succeeded.
Unsaved changes deserve care as well. If someone edits their bio and then taps back, silently throwing the change away is frustrating. A simple safeguard compares the fields with their initial values and, if anything has changed, asks "Discard changes?" before leaving. For long text such as a caption, keeping a draft in the app's local state means an interruption, such as a phone call, does not cost the user their writing.
Keyboards and focus
The on-screen keyboard covers roughly the bottom 40 percent of a phone screen. A form must remain usable when it appears: the page should scroll so the focused field stays visible, and buttons at the bottom should either move up with the keyboard or be reachable by scrolling. FlutterFlow pages adjust for the keyboard by default; placing the form in a scrollable column makes sure every field can be reached. Tapping outside a field should dismiss the keyboard, which can be done by wrapping the page in a gesture that unfocuses the current field.
The next parts finish the remaining pages: the search page with its results grid and accounts tab, the new-post pages with the camera and caption details, and the bottom navigation bar's final order, before the series turns to the Supabase database and connects every form to real data.
Practice tasks
- A caption field uses a 16-point font with a 1.5 line height and 10 points of padding top and bottom. How tall must it be to show five lines?
- Which keyboard type and capitalisation would you choose for name, username, email and verification code fields?
- Write a validation rule, in words, for usernames that allows 3 to 30 letters, numbers, dots or underscores.
- Why should an edit page prefill its fields with the current values?
- Rewrite this error message to be helpful: "Error: field invalid".
- Explain why checking that a username is unique needs both a query and a database constraint.
This course book is available to read online only at tech-academy.chrysolites.org.