From d873efd9821974868558905800132f28ed0aa824 Mon Sep 17 00:00:00 2001 From: Pinkesh Date: Thu, 5 Jun 2025 11:35:24 +0530 Subject: [PATCH 1/2] Add code snippet for ReviewStatus enum --- docs/ff-concepts/adding-customization/code-file.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/ff-concepts/adding-customization/code-file.md b/docs/ff-concepts/adding-customization/code-file.md index 182f2f46..0c46e50e 100644 --- a/docs/ff-concepts/adding-customization/code-file.md +++ b/docs/ff-concepts/adding-customization/code-file.md @@ -139,7 +139,8 @@ 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: @@ -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) From 18dc9a963c68cd5ac30e145ea02d29990a85e603 Mon Sep 17 00:00:00 2001 From: Pinkesh Date: Thu, 5 Jun 2025 12:16:48 +0530 Subject: [PATCH 2/2] Clarification regarding creating instance --- docs/ff-concepts/adding-customization/code-file.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ff-concepts/adding-customization/code-file.md b/docs/ff-concepts/adding-customization/code-file.md index 0c46e50e..012c45dc 100644 --- a/docs/ff-concepts/adding-customization/code-file.md +++ b/docs/ff-concepts/adding-customization/code-file.md @@ -148,7 +148,7 @@ When you create an instance of a class, you can: - 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.