You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/resources/control-flow/functions/loops.md
+37-5Lines changed: 37 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,14 +7,46 @@ sidebar_position: 5
7
7
keywords: [Loops, Backend Query, Backend Logic, Control Flow, FlutterFlow]
8
8
---
9
9
10
-
Sometimes, you might want to trigger certain actions multiple times. For example, an app might fetch data from a server, and you want to handle network errors by retrying the request up to a certain number of times.
10
+
# Loops
11
11
12
-
:::info
13
-
Every loop requires a condition, and the actions within the loop will continue to trigger as
14
-
long as the condition holds true. When the condition becomes false, the loop terminates, and the next actions in the workflow will trigger.
15
-
:::
12
+
**Loops** in FlutterFlow allow you to perform repetitive tasks without writing complex code. This is useful when working with lists of data or when you want to repeat actions a certain number of times.
13
+
14
+
There are two types of loops supported in FlutterFlow:
15
+
16
+
## While Condition Loops
17
+
18
+
A **While Condition** loop requires a condition. The actions within the loop will continue to trigger as long as the condition holds true. When the condition becomes false, the loop terminates, and the next actions in the workflow will trigger.
19
+
20
+
For example, you can use a While Condition loop to continuously check if a user is still within a geofenced area. As long as the condition `isUserInLocation == true` holds, the app might keep checking for updates or show a live indicator.
16
21
17
22

23
+
24
+
## Over List
25
+
26
+
This loop type lets you iterate over a list of items to perform actions for each item in the list.
27
+
28
+
For example, if you have a list of items in a shopping cart and want to calculate the total price or apply a discount to each item, you can use Over List to go through each product and perform a calculation for each one.
29
+
30
+
You can also customize how the loop iterates:
31
+
32
+
-**Start Index**: Where the loop starts (default is `0`).
33
+
-**End Index**: Where the loop ends (default is the length of the list).
34
+
-**Step Size**: Interval between each iteration (e.g., set to `2` to loop through every second item).
35
+
-**Reverse Order**: Enables the loop to iterate from the end of the list to the beginning (e.g., showing the latest messages first).
36
+
37
+

38
+
39
+
Inside a loop, you can access the current item and its index. This gives you the ability to work with each item individually, such as displaying item-specific data and making calculations.
You can also add a loop inside another loop to handle related data structures. For example, looping through orders and then looping through each order’s line items.
0 commit comments