Skip to content

Commit 4c23d80

Browse files
committed
Update custom data types docs: added details on instance creation.
1 parent b588624 commit 4c23d80

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

docs/resources/data-representation/custom-data-types.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,42 @@ When naming custom data types, always use **UpperCamelCase**, as recommended by
6868

6969
## Accessing Custom Data Type
7070

71-
After creating the custom data type, you can use it to create variables, such as an app state variable, and then access them. Here's an [example](app-state.md#app-state-variables).
71+
After creating a custom data type, it’s treated internally as a [Dart class](https://dart.dev/language/classes). However, just defining the custom data type doesn’t hold any real data. To work with actual data, such as storing a user profile or a review, you need to create an **instance** of custom data type.
72+
73+
Creating an instance allows you to:
74+
75+
- Assign specific values to each field in your custom data type.
76+
- Store the instance in app state, page state, or pass it between widgets.
77+
- Access individual fields wherever needed.
78+
79+
To create an instance of a custom data type, first you need to [create a state variable](../../ff-concepts/state-management/state-variables.md#creating-state-variables) (of type **Data Type**) 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 Data Type Object > Project Data Type**. Choose the data type you want to use. After that, set values for each of the required fields.
80+
81+
82+
<div style={{
83+
position: 'relative',
84+
paddingBottom: 'calc(56.67989417989418% + 41px)', // Keeps the aspect ratio and additional padding
85+
height: 0,
86+
width: '100%'}}>
87+
<iframe
88+
src="https://demo.arcade.software/qNNwqEm7vrvuWszmhf9R?embed&show_copy_link=true"
89+
title=""
90+
style={{
91+
position: 'absolute',
92+
top: 0,
93+
left: 0,
94+
width: '100%',
95+
height: '100%',
96+
colorScheme: 'light'
97+
}}
98+
frameborder="0"
99+
loading="lazy"
100+
webkitAllowFullScreen
101+
mozAllowFullScreen
102+
allowFullScreen
103+
allow="clipboard-write">
104+
</iframe>
105+
</div>
106+
<p></p>
72107

73108
### Custom Data Type in Custom Code
74109
Sometimes, you might want to access the custom data type in your custom code. Our custom code editor allows you to receive and pass data into a variable of a custom data type. For example, you could manipulate or analyze the data as needed, and then return the modified result in the custom data type.

0 commit comments

Comments
 (0)