diff --git a/docs/ff-concepts/layout/responsive-layout.md b/docs/ff-concepts/layout/responsive-layout.md index 5783287f..d9f99ee0 100644 --- a/docs/ff-concepts/layout/responsive-layout.md +++ b/docs/ff-concepts/layout/responsive-layout.md @@ -85,7 +85,7 @@ For `Row 2`, set its Expansion property to *Flexible* (the middle icon) and assi ![test-expansion.avif](imgs/test-expansion.avif) -I encourage you to test with different web dimensions and sizes to see how well this adapts. +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`? diff --git a/docs/ff-concepts/layout/responsive-widgets/flex-widget.md b/docs/ff-concepts/layout/responsive-widgets/flex-widget.md new file mode 100644 index 00000000..f94af21e --- /dev/null +++ b/docs/ff-concepts/layout/responsive-widgets/flex-widget.md @@ -0,0 +1,90 @@ +--- +slug: /concepts/layouts/flex +title: Flex +description: Learn how to add the Flex widget in your FlutterFlow app. +tags: [Flex, Widget, Concepts] +sidebar_position: 2 +keywords: [FlutterFlow, Wrap, Concepts] +--- + +# Flex + +The **Flex** widget can be used as an alternative to **Row** and **Column**. It allows you to dynamically set the layout axis (horizontal or vertical) based on specific conditions or logic. This is especially useful for creative responsive layouts - where child elements should be horizontal when the screen is wide, and vertical when the screen is narrow. + +![flex.png](imgs/flex.png) + + + +## Adding Flex Widget + +To use the Flex widget, add it from the **Layout Elements** section of the **Widget Palette**, then add child widgets inside it. 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. + +Consider an ecommerce 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. + +
+ +
+

+ +Here's another example of using a Flex widget on a create account page to dynamically align the signup fields based on screen size. + +
+ +
+

+ +:::tip[Best Practices] + +- 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). +- 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. +- 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. + +::: + +## Customization + +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) work the same way they do for the Column and Row widgets. + + diff --git a/docs/ff-concepts/layout/responsive-widgets/imgs/flex.png b/docs/ff-concepts/layout/responsive-widgets/imgs/flex.png new file mode 100644 index 00000000..10eda774 Binary files /dev/null and b/docs/ff-concepts/layout/responsive-widgets/imgs/flex.png differ