Skip to content

Commit ec00bbc

Browse files
authored
Merge branch 'main' into feature/import-figma-frame
2 parents f8121d5 + 01fce3b commit ec00bbc

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

docs/ff-concepts/adding-customization/code-file.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,16 @@ You need to create an instance of a class so you can work with actual data and u
139139
);
140140
```
141141

142-
- You can reuse the same class structure multiple times with different review data.
142+
- In FlutterFlow, you will store the instance of the custom class in the [state variables](../../ff-concepts/state-management/state-variables.md#state-variables) of your app, page, or component.
143+
- You can create multiple instances of the same class, reusing the same structure multiple times, each with different review data.
143144

144145
When you create an instance of a class, you can:
145146

146147
- Store actual review details.
147148
- Access and update the fields (e.g., `review1.rating` or `review1.comment`).
148149
- Call methods that do something with that data (e.g., `review1.markHelpful()` or `review1.shortComment()`).
149150

150-
To create an instance of a custom class, open the **Set from Variable** dialog and select **Create Custom Class Instance**. Choose the class you want to use, then select the class name from the **Constructor** dropdown. After that, set values for each of the required fields.
151+
To create an instance of a custom class, first you need to [create a state variable](../../ff-concepts/state-management/state-variables.md#creating-state-variables) (of type Custom Class) that will hold the instance. Then, to create and add the instance to the state variable, open the **Set from Variable** dialog and select **Create Custom Class Instance**. Choose the class you want to use, then select the class name from the **Constructor** dropdown. After that, set values for each of the required fields.
151152

152153

153154
<div style={{
@@ -412,7 +413,15 @@ Use the **Call Static Method** action to run a static method of your class. For
412413
413414
Similar to how you add a custom class, you can also add Custom Enums in your app. [Enums](../../resources/data-representation/enums.md) are a great way to define a fixed set of values, such as user roles, order statuses, or content types. Once parsed, these enums become available throughout your app and can be used in dropdowns, conditionals, and UI bindings.
414415
415-
For example, you could define an enum called `ReviewStatus` with values like `pending`, `approved`, and `rejected`.
416+
For example, you could define an enum called `ReviewStatus` with values like `pending`, `approved`, and `rejected`. Here's the code snippet for it:
417+
418+
```jsx
419+
enum ReviewStatus {
420+
pending,
421+
approved,
422+
rejected,
423+
}
424+
```
416425

417426
![custom-enums.avif](imgs/custom-enums.avif)
418427

0 commit comments

Comments
 (0)