Skip to content

Commit 2893d29

Browse files
committed
Added Flex widget info
1 parent ed84341 commit 2893d29

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
---
2+
slug: /concepts/layouts/flex
3+
title: Flex
4+
description: Learn how to add the Flex widget in your FlutterFlow app.
5+
tags: [Flex, Widget, Concepts]
6+
sidebar_position: 2
7+
keywords: [FlutterFlow, Wrap, Concepts]
8+
---
9+
10+
# Flex
11+
12+
The **Flex** widget can be used as an alternative to **Rows** and **Columns**, which allows you to dynamically set the layout axis (horizontal or vertical) based on specific conditions or logic. This is useful in scenarios where the layout needs to adapt to different screen sizes or device orientations.
13+
14+
For instance, the Flex widget can lay out items horizontally on wider screens and switch to a vertical layout when screen space is limited, ensuring an optimal user experience on any device.
15+
16+
:::tip[Possible use cases]
17+
18+
- **Responsive Dashboards**: In admin dashboards, the Flex widget can adjust charts, tables, and stats based on screen size or orientation.
19+
- **Profile Layouts**: In social media profiles, the Flex widget can arrange pictures, usernames, and stats.
20+
- **Cards Layout:** In credit card management apps, Flex can be used to layout credit cards dynamically, switching between a horizontal or vertical layout based on screen width.
21+
22+
:::
23+
24+
## Adding Flex Widget
25+
26+
To use the Flex widget, add it from the **Layout Elements**, then add child widgets inside it. Then, from the properties panel, set a condition for the **Is Horizontal** property. When this condition evaluates to TRUE, the items will be laid out horizontally.
27+
28+
Consider an e-commerce app where recent orders are displayed vertically on mobile devices and switch to a horizontal layout on larger screens to make better use of the available space.
29+
30+
<div style={{
31+
position: 'relative',
32+
paddingBottom: 'calc(56.67989417989418% + 41px)', // Keeps the aspect ratio and additional padding
33+
height: 0,
34+
width: '100%'}}>
35+
<iframe
36+
src="https://demo.arcade.software/3zWIgGDDec21fNIeCVOU?embed&show_copy_link=true"
37+
title=""
38+
style={{
39+
position: 'absolute',
40+
top: 0,
41+
left: 0,
42+
width: '100%',
43+
height: '100%',
44+
colorScheme: 'light'
45+
}}
46+
frameborder="0"
47+
loading="lazy"
48+
webkitAllowFullScreen
49+
mozAllowFullScreen
50+
allowFullScreen
51+
allow="clipboard-write">
52+
</iframe>
53+
</div>
54+
<p></p>
55+
56+
Here's another example of using a Flex widget on a create account page to dynamically align the signup fields based on screen size.
57+
58+
<div style={{
59+
position: 'relative',
60+
paddingBottom: 'calc(56.67989417989418% + 41px)', // Keeps the aspect ratio and additional padding
61+
height: 0,
62+
width: '100%'}}>
63+
<iframe
64+
src="https://demo.arcade.software/HPk574WhIatWbJBdlxtf?embed&show_copy_link=true"
65+
title=""
66+
style={{
67+
position: 'absolute',
68+
top: 0,
69+
left: 0,
70+
width: '100%',
71+
height: '100%',
72+
colorScheme: 'light'
73+
}}
74+
frameborder="0"
75+
loading="lazy"
76+
webkitAllowFullScreen
77+
mozAllowFullScreen
78+
allowFullScreen
79+
allow="clipboard-write">
80+
</iframe>
81+
</div>
82+
<p></p>
83+
84+
:::tip[Best Practices]
85+
86+
- If you only need a simple vertical or horizontal arrangement, consider using [**Row**](../../../resources/ui/widgets/composing-widgets/rows-column-stack.md) or [**Column**](../../../resources/ui/widgets/composing-widgets/rows-column-stack.md).
87+
- For very large numbers of children, consider using [**ListView**](../../../resources/ui/widgets/composing-widgets/list-grid.md#listview-widget) or [**GridView**](../../../resources/ui/widgets/composing-widgets/list-grid.md#gridview-widget) instead of **Flex**, as they offer better performance for scrolling large lists of items.
88+
- When the content exceeds the screen limit, you can enable scrolling to make the content accessible. However, if you want to avoid scrolling altogether and still fit all the content on the screen, consider using a [**Wrap**](wrap-widget.md) widget.
89+
90+
:::
91+
92+
## Customization
93+
94+
When **Is Horizontal** property is disabled, the Flex widget behaves like a Column, and when enabled, it acts as a Row. Settings like [main axis alignment](../../../resources/ui/widgets/composing-widgets/rows-column-stack.md#main-axis), [cross axis alignment](../../../resources/ui/widgets/composing-widgets/rows-column-stack.md#cross-axis), [scrollability](../../../resources/ui/widgets/composing-widgets/rows-column-stack.md#scrollability), and [spacing](../../../resources/ui/widgets/composing-widgets/rows-column-stack.md#spacing) works the same way they do for the Column and Row widgets.
95+
96+

0 commit comments

Comments
 (0)