Skip to content

Commit 1932f83

Browse files
Update "Code Expression" to "Inline Function" (#367)
* Update "Code Expression" to "Inline Function" * Apply suggestions from code review --------- Co-authored-by: Pooja Bhaumik <[email protected]>
1 parent 45b5a32 commit 1932f83

File tree

9 files changed

+27
-39
lines changed

9 files changed

+27
-39
lines changed

docs/ff-concepts/animations/widget_animations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ If you notice carefully, the items appear in a staggered fashion. This can be ac
208208

209209
Select the item in the list and add the Slide animation.
210210

211-
In the Delay property, open the variable menu and add a [code expression](../../resources/control-flow/functions/utility-functions.md#code-expressions) to calculate the delay value based on the item's index. For this example, we use the formula `[index] * 100`, where `index` represents the position of the item, and `100` is the delay in milliseconds. This means the first item will slide in after 100 ms, the second after 200 ms, and so on, creating a staggered animation effect.
211+
In the Delay property, open the variable menu and add a [inline function](../../resources/control-flow/functions/utility-functions.md#inline-function) to calculate the delay value based on the item's index. For this example, we use the formula `[index] * 100`, where `index` represents the position of the item, and `100` is the delay in milliseconds. This means the first item will slide in after 100 ms, the second after 200 ms, and so on, creating a staggered animation effect.
212212

213213
<div style={{
214214
position: 'relative',

docs/ff-integrations/payments/razorpay.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ Follow the steps below to add this action:
137137
3. Search and select the **Razorpay Payment** (under *Integrations*) action.
138138
4. Enter or use a variable for specifying the total amount under the **Amount** section. **Note** that the value should be specified in the currency's smallest unit.
139139
- For example, *$24.99* should be passed as *2499* (as a round-off integer; otherwise, it would be automatically rounded); similarly, for an amount of ₹120.00, 12000 should be passed.
140-
- Most probably, you'll specify this value from a variable. If you do so, you might need this [code expression](../../resources/control-flow/functions/utility-functions.md#code-expressions) to convert the total amount in the required format: `amount.toStringAsFixed(2).replaceAll(".", "");`
140+
- Most probably, you'll specify this value from a variable. If you do so, you might need this [inline function](../../resources/control-flow/functions/utility-functions.md#inline-function) to convert the total amount in the required format: `amount.toStringAsFixed(2).replaceAll(".", "");`
141141
5. Enter the **Currency Code** to be used for the amount, for example, *INR*, *USD*, *EUR*, or *BRL*. Make sure you enter a valid currency code; otherwise, the transaction won't go through. Download the complete [list of supported currencies](https://razorpay.com/docs/build/browser/assets/images/international-currency-list.xlsx).
142142
<p></p>
143143

docs/resources/control-flow/backend-logic/api/soap-api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ You can now proceed to display the country list in *HomePage*. Here are the step
309309
<p></p>
310310

311311
4. On ListView, [generate dynamic children](../../../ui/widgets/composing-widgets/generate-dynamic-children.md) using the page state variable.
312-
5. The page state variable stores the country name and code as a single string (e.g., Australia - AT). To display the name and code separately in a *ListTile*, we can use a [code expression](../../../control-flow/functions/utility-functions.md#code-expressions). To display the country name, we can use `var1.split("-")[1].trim()`, where `var1` is the current item in the list. To display the country code, we can use the same expression and replace `[1]` with `[0]`.
312+
5. The page state variable stores the country name and code as a single string (e.g., Australia - AT). To display the name and code separately in a *ListTile*, we can use a [inline function](../../../control-flow/functions/utility-functions.md#inline-function). To display the country name, we can use `var1.split("-")[1].trim()`, where `var1` is the current item in the list. To display the country code, we can use the same expression and replace `[1]` with `[0]`.
313313

314314
<div style={{
315315
position: 'relative',

docs/resources/control-flow/backend-logic/api/streaming-api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ id: 2
356356
```
357357
The Server Sent Event Data JSON will be `null` because the data cannot be parsed as JSON.
358358

359-
You can fix this by using the following expression inside the [Code Expression](../../../control-flow/functions/utility-functions.md#code-expressions) to handle the `null` case:
359+
You can fix this by using the following expression inside the [Inline Function](../../../control-flow/functions/utility-functions.md#inline-function) to handle the `null` case:
360360

361361
```
362362
responseData ?? ''

docs/resources/control-flow/functions/utility-functions.md

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ FlutterFlow has the following built-in functions:
2121
* **Combine Text:** A built-in function that lets you concatenate strings, making it easy to join
2222
multiple text elements together seamlessly.
2323

24-
* **Code Expression:** This feature allows you to perform simple calculations and data
25-
manipulations
26-
quickly and efficiently.
24+
* **Inline Function:** This feature allows you to perform simple calculations and data manipulations quickly and efficiently.
2725

2826

2927

@@ -87,34 +85,22 @@ together, with the same text style applied to all of them. If you need to combin
8785
values with different text styles for each, consider using the **[RichText](../../ui/widgets/basic-widgets/text.md#richtext-widget)** widget.
8886
:::
8987

90-
## Code Expressions
88+
## Inline Function
89+
Often times, you may need to quickly format data, convert a data type from one form to another, or perform a simple calculation before setting the variable to a data source, such as a widget value source.
9190

92-
Oftentimes, you may need to quickly format data, convert a data type from one form to another,
93-
or perform a simple calculation before setting the variable to a data source, such as a widget
94-
value source.
91+
Inline Function is a piece of code that combines operators, variables, and/or values to produce a result. It can be used for arithmetic and logical operations, among other tasks.
9592

96-
**Code Expression** built-in functions can help with
97-
these tasks. A code expression is a piece of code that combines operators, variables, and/or values
98-
to produce a result. It can be used for arithmetic and logical operations, among other tasks.
93+
To add inline function, open the Set from Variable dialog wherever it's possible to set a dynamic value and choose the values that will be part of the inline function.
9994

100-
To perform a code expression, open the Variable Setter dialog wherever it's possible to set a
101-
dynamic value and choose the values that will be part of the code expression.
95+
For example, we may want to quickly calculate the discount amount of a product where the discount is 18% of the MRP of the product. The expression would be `cost - (cost * discount)`.
10296

103-
For example, we may want to quickly calculate the discount amount of a product where the discount is
104-
18% of the MRP of the product.
97+
**Precedence of operations**
10598

106-
The expression would be `cost - (cost * discount)`.
99+
Inline Function for math operations follow typical precedence (e.g., multiplication/division before addition/subtraction), but parentheses can change the order.
107100

108-
:::warning[Precedence of operations]
109-
Code expressions for math operations follow typical precedence (e.g., multiplication/division before
110-
addition/subtraction), but parentheses can change the order.
111-
:::
112-
113-
In this case, the variables we need are `cost` and `discount`.
101+
In this case, the variables we need are `cost` and `discount`.
114102

115-
So, we create two arguments in the **Code Expression** dialog where they hold the value of `cost`
116-
and `discount`, assign the data type for each of the arguments, and define the return type of the
117-
final value. In this case, the return type is a `double` since it holds the **subtotal** amount.
103+
So, we create two arguments in the **Inline Function** dialog where they hold the value of `cost` and `discount`, assign the data type for each of the arguments, and define the return type of the final value. In this case, the return type is a `double` since it holds the **subtotal** amount.
118104

119105
<div style={{
120106
position: 'relative',
@@ -123,7 +109,7 @@ final value. In this case, the return type is a `double` since it holds the **su
123109
width: '100%'
124110
}}>
125111
<iframe
126-
src="https://demo.arcade.software/I6UcltVn7ssAIWmipeFY?embed&show_copy_link=true"
112+
src="https://demo.arcade.software/qM8kjAlMJl6WyH3tXN4X?embed&show_copy_link=true"
127113
title=""
128114
style={{
129115
position: 'absolute',
@@ -142,10 +128,9 @@ final value. In this case, the return type is a `double` since it holds the **su
142128
</iframe>
143129
</div>
144130

145-
Now you can write the code expression in the **Expression** field and click on **Check Errors** to
146-
see if the expression is valid. If it is valid, you will see the generated code for the same.
131+
Now you can write the inline function in the **Expression** field and click on **Check Errors** to see if the expression is valid. If it is valid, you will see the generated code for the same.
147132

148-
The arguments in a Code Expression can take the following properties:
133+
The arguments in a Inline Function can take the following properties:
149134

150135
| DataType | Supports Nullable | Supports List |
151136
|----------|-------------------|---------------|
@@ -172,12 +157,10 @@ Here are some common expressions you can use for your business logic:
172157

173158

174159

175-
176-
177160
## Custom Functions
178161

179-
You can also use custom functions to handle slightly more complex calculations or to process a wider range of data types that are not supported in Code Expression.
162+
You can also use custom functions to handle slightly more complex calculations or to process a wider range of data types that are not supported in Inline Function.
180163

181164
:::info
182165
Learn more about [**Custom Functions**](../../../ff-concepts/adding-customization/custom-functions.md).
183-
:::
166+
:::

docs/resources/control-flow/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ There are different types of functions you can use in your app. Some examples in
6565
tasks, such as
6666
formatting
6767
data or performing calculations. In FlutterFlow, you can use
68-
[**Code Expression**](functions/utility-functions.md#code-expressions) for simple data
68+
[**Inline Function**](functions/utility-functions.md#inline-function) for simple data
6969
manipulation tasks or use the
7070
**[Combine Text](functions/utility-functions.md#combine-text)** built-in
7171
function to concatenate strings.

docs/resources/control-flow/user-interactivity/forms/form-widgets/dropdown.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ You might need to disable a dropdown when certain conditions are not yet met or
244244
To disable the dropdown:
245245

246246
1. Select the **DropDown** widget, move to the **Properties Panel > DropDown Search >** enable **Disable Dropdown** option.
247-
2. Click on **Unset** and select the source that returns the boolean value (i.e., True or False), such as boolean variable, [Conditions](../../../../../resources/functions/conditional-logic), [Code Expression](../../../../../resources/functions/utility#code-expressions).
247+
2. Click on **Unset** and select the source that returns the boolean value (i.e., True or False), such as boolean variable, [Conditions](../../../../../resources/functions/conditional-logic), [Inline Function](../../../../../resources/control-flow/functions/utility-functions.md#inline-function).
248248

249249
![Disabling dropdown](../../imgs/disabling-dropdown.png)
250250

docs/resources/ui/widgets/built-in-widgets/sticky-header.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ com/embed/39bb5fc9068f4a759a4b0d6fd62e3f16?sid=ed5c274e-f1e0-4830-9702-dd35ac2d6
166166
4. Now, inside the *StickyHeader* *Content* section, add the **ListView** with a **Container**
167167
inside to display the list of matching contacts.
168168

169-
1. On this ListView, generate dynamic children from a variable that holds all the contacts. But while doing so, filter the list and extract only matching contacts using [Code expression](../../../../resources/control-flow/functions/utility-functions.md#code-expressions).
169+
1. On this ListView, generate dynamic children from a variable that holds all the contacts. But while doing so, filter the list and extract only matching contacts using [Inline Function](../../../../resources/control-flow/functions/utility-functions.md#inline-function).
170170
2. Now you can display the contact's details, such as name, inside the UI.
171171

172172
<div class="video-container"><iframe src="https://www.loom.

firebase.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2407,6 +2407,11 @@
24072407
"source": "/marketplace/creators-hub/submit-item-for-reivew",
24082408
"destination": "/marketplace/creators-hub/submit-item-for-review",
24092409
"type": 301
2410+
},
2411+
{
2412+
"source": "/resources/functions/utility/#code-expressions",
2413+
"destination": "/resources/functions/utility/#inline-function",
2414+
"type": 301
24102415
}
24112416
]
24122417
}

0 commit comments

Comments
 (0)