Skip to content

Custom Class Improvements #382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions docs/ff-concepts/adding-customization/code-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,16 @@ You need to create an instance of a class so you can work with actual data and u
);
```

- You can reuse the same class structure multiple times with different review data.
- 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.
- You can create multiple instances of the same class, reusing the same structure multiple times, each with different review data.

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

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

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.
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.


<div style={{
Expand Down Expand Up @@ -412,7 +413,15 @@ Use the **Call Static Method** action to run a static method of your class. For

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.

For example, you could define an enum called `ReviewStatus` with values like `pending`, `approved`, and `rejected`.
For example, you could define an enum called `ReviewStatus` with values like `pending`, `approved`, and `rejected`. Here's the code snippet for it:

```jsx
enum ReviewStatus {
pending,
approved,
rejected,
}
```

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

Expand Down