Skip to content

Responsive Layout

FlutterFlow Studio is great at creating applications adaptable to a wide range of screen sizes, devices, and platforms. Ensuring that our screens maintain their aesthetic appeal across all these variations is crucial. Below, we outline various methods to enhance the responsiveness of your UI screens.

Note: Please check out the examples in the order they’re given, as they use the same example. Jumping to sections might make things confusing.

Global Properties

Let’s start by demonstrating how screen width and height values change when you switch between devices in Test Mode.

First, create a new project. In the Home Page, under a Column parent, add two Text widgets. Label one “Screen Width” and the other “Screen Height.”

The widget tree and canvas of a page where a Column holds two Text widgets that show Screen Width and Screen Height.The widget tree and canvas of a page where a Column holds two Text widgets that show Screen Width and Screen Height.

Next, we’ll display the changing values alongside these titles. For each Text widget, set its value to a variable. Select Combine Text from the options. Your first Text value should be either “Screen Width: “ or “Screen Height: “.

Then, add another Text value that will show the corresponding value. This second Text value is also set from a variable. Choose ‘Global Properties,’ and then select either ‘Screen Width’ or ‘Screen Height’ from the list. These options hold the current screen width/height values. Repeat this process for both Text widgets.

The Set from Variable menu with Global Properties expanded, listing Screen Width and Screen Height.The Set from Variable menu with Global Properties expanded, listing Screen Width and Screen Height.

Now, when you switch to Test Mode and try out different devices, you’ll see the screen width and height values update accordingly.

running-app-on-test-mode-for-desktop-device-sizes.avif

This is to show you that these screen values are always accessible as global properties. You can use them to design your UI logic effectively.

Expanded & Flex

Let’s explore a fundamental method to make columns and rows adapt to different screen widths and heights. While designing a Row or Column, it’s important to avoid assigning fixed sizes to the children, unless specifically required by the design.

Take, for instance, the navigation bar we’re creating for our web version. It includes the page name, several navigation icons, and a search bar. Notice how the search bar adjusts its length based on the available width. This adaptability is achieved because the widths of the children are set relative to the available space in the horizontal section.

web-version-of-our-shopping-app-example.gif

To design the same navbar, create the following widget hierarchy:

- Container (named as webHeader)
- Row
- Row
- TextField (named as searchBar)
- IconButton

The second Row is further broken down into the following:

- Row 2
- Text (named as pageName)
- Row 3 (named as navIcons)
- IconButton
- IconButton
- IconButton

The Widget Tree labels both nested rows Row. The names Row 2 and Row 3 only tell them apart in this guide.

Widget Tree showing ProductList > Column > webHeader > Row with a nested Row (pageName, navIcons with three IconButtons), searchBar, and IconButton, next to the canvas with the header Row selected.Widget Tree showing ProductList > Column > webHeader > Row with a nested Row (pageName, navIcons with three IconButtons), searchBar, and IconButton, next to the canvas with the header Row selected.

A TextField inside a Row needs a width or an Expansion setting, so set the searchBar’s Expansion to Expanded (the third icon) for now. The search bar then occupies the maximum available space. However, we want both Row 2 and the searchBar to share the space equally. To achieve this, simply adjust the Widget properties.

For Row 2, set its Expansion property to Flexible (the middle icon) and assign a Flex value of 1. Repeat the same steps for the searchBar. This change ensures they are allocated space in a 1:1 ratio, based on what’s available. After this adjustment, you’ll notice that the remaining space, following the placement of the search IconButton on the right, is evenly divided between Row 2 and the searchBar.

Editor with searchBar selected in the Widget Tree, the header split evenly on the canvas, and the Expansion row set to Flexible with a Flex value of 1.Editor with searchBar selected in the Widget Tree, the header split evenly on the canvas, and the Expansion row set to Flexible with a Flex value of 1.

We encourage you to test with different web dimensions and sizes to see how well this adapts.

Depending on your design needs, there are various approaches to managing space. Let’s consider a different scenario: What if we want the searchBar to always occupy 40% of the screen width, with Row 2 taking up the remaining space after placing the searchBar and search IconButton?

To do this, first set the searchBar’s Width to 40 with % selected, and then set its Expansion to Default (the first icon). Set the width first, because the editor doesn’t let a TextField in a Row use Default without one.

searchBar properties with Expansion set to Default and Width set to 40 with % selected.searchBar properties with Expansion set to Default and Width set to 40 with % selected.

Next, adjust the Row 2 widget’s Expansion setting to Expanded (the third icon). With these settings, you’ll see that Row 2 now occupies all the space left over after allocating 40% to the searchBar and placing the search IconButton.

Note: We’ve also styled the searchBar with a fill color, rounded corners, and a prefix icon to improve its appearance.

ProductList page with the Categories title and nav icons on the left, a 40% width search bar reading 'Search for your shoes...' and a search icon on the right, and three category cards below.ProductList page with the Categories title and nav icons on the left, a 40% width search bar reading 'Search for your shoes...' and a search icon on the right, and three category cards below.

You can also go ahead and improve the spacing between the pageName and navIcons by adjusting the MainAxisAlignment to Space Between (represented by the last icon).

Feel free to try this out with different screen sizes to see how it effectively adapts to the available space.

Wrap method

Another effective method to enhance the responsiveness of a row or column containing multiple items is through the use of the Wrap widget.

Let’s consider a scenario with a Row of category cards.

Widget Tree with a Row selected that holds card1, card2, and card3, next to the canvas showing three category cards: Limited Edition, Casual Shorts, and Shoes.Widget Tree with a Row selected that holds card1, card2, and card3, next to the canvas showing three category cards: Limited Edition, Casual Shorts, and Shoes.

You might observe that when the screen size is adjusted to resemble mobile dimensions, the cards begin to get cut off at the edges.

row-card-resize.gif

To resolve this issue, simply replace the parent Row widget with a Wrap widget.

Make sure to set the Wrap Direction to ‘Horizontal’ in the Wrap properties. You’ll then see that the previously overflowing cards neatly move to the next line, as illustrated in the example.

row-card-resize.gif

The Wrap widget efficiently manages layout for varying screen sizes by automatically adjusting its children into multiple rows or columns. It prevents overflow and ensures a clean, responsive design, especially useful for adapting content like category cards from desktop to mobile views.

Responsive Breakpoints

Moving on to more complex layout scenarios, where the UI significantly differs between mobile and web platforms, it’s important to first understand breakpoints.

Breakpoints in responsive design are like thresholds for different screen sizes. They act as specific points where the layout of a user interface meets a certain screen size requirement and then changes to accommodate it. When the screen size crosses one of these thresholds, the layout adjusts.

FlutterFlow Studio has default breakpoints for different screen sizes, but you can also adjust these to better suit your app’s design needs.

Customize Responsive Breakpoints

Open the Theme panel, and under Design system & app theme, click Breakpoints. The popover shows the widest screen, in pixels, that each layout applies to. You can change these values if needed.

Theme panel filtered to Design system & app theme > Breakpoints, with the Breakpoints popover showing Mobile up to 599, Tablet up to 899, Tablet (landscape) up to 1199, and Desktop for everything wider.Theme panel filtered to Design system & app theme > Breakpoints, with the Breakpoints popover showing Mobile up to 599, Tablet up to 899, Tablet (landscape) up to 1199, and Desktop for everything wider.

The following sections will also rely heavily on Responsive Visibility, so let’s proceed.

Visibility of Nav Bar & App Bar

In many designs, the App Bar and Nav Bar are typically included in mobile or mobile + tablet screens, and often omitted in desktop formats. FlutterFlow Studio makes it easy to enable or disable the Nav Bar and App Bar.

Just go to App Settings, select Nav Bar & App Bar, and toggle the ‘Show Nav Bar’ option. Upon enabling it, the Responsive Visibility icons appear next to the toggle. Icons for mobile, tablet, tablet (landscape), and desktop let you choose where the Nav Bar should appear. The Nav Bar needs at least two pages, which you add under Pages.

Generally, it’s advisable to enable it only for mobile, or mobile and tablet. Let’s follow these steps to configure it for our app.

App Settings with Nav Bar & App Bar selected, Show Nav Bar on, and Responsive Visibility set to mobile and tablet only, with the Layout preview and the ProductList and LayoutDemo pages listed under Pages.App Settings with Nav Bar & App Bar selected, Show Nav Bar on, and Responsive Visibility set to mobile and tablet only, with the Layout preview and the ProductList and LayoutDemo pages listed under Pages.

Now, when testing directly in our editor, observe how the navbar appears only for mobile and tablet screen sizes. This same approach can be applied to the App bar as well.

appbar-navbar-visibility-resize.gif

Responsive Visibility

In our previous examples, we improved many aspects, but some responsive issues still remained. For instance, our NavBar displayed the same navigation icons on both top header and bottom navbar. Additionally, when the screen width was reduced to mimic mobile dimensions, the header elements became cramped and difficult to interact with.

To address this, we can leverage FlutterFlow Studio’s Responsive Visibility feature to implement distinct AppBar and SearchBar designs for mobile, while maintaining the current design for web.

Imagine we’ve created a new widget, mobileAppBar , and added it to our layout. This widget cleverly separates the categories header and search bar vertically and includes a back navigation button. The goal is to activate this mobile-friendly layout for mobile and tablet screens, while preserving the ‘webHeader’ for tablet (landscape) and desktop views.

responsive-visibility.avif

To implement this, we can go to its widget properties and toggle the device icons as shown in the following demo.

And now you have a more responsive screen for this shopping app use case that looks good in both mobile and desktop formats.

With these adjustments, your shopping app now boasts a highly responsive screen that seamlessly adapts to both mobile and desktop formats. This ensures an optimal user experience across all devices, maintaining both functionality and aesthetic appeal.

Responsive Value

Responsive Values allow you to define different property values, such as widths, heights, font sizes, or padding, for different device sizes (mobile, tablet, desktop, and wide). At runtime, your app evaluates the screen width and automatically applies the appropriate value based on your configurations.

To set a responsive value, select a widget and choose a property that supports responsiveness. Click Set from Variable > Responsive Value, then enter different values for each screen size:

  • Mobile (below Breakpoint Small)
  • Tablet (below Breakpoint Medium)
  • Desktop (below Breakpoint Large)
  • Wide (above Breakpoint Large)

As you preview on different devices, the property will automatically adjust based on the selected screen size.

Last updated on