You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/ff-concepts/state-management/state-management.md
+24-14Lines changed: 24 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,10 +2,12 @@
2
2
title: State Management
3
3
description: An overview of state management in FlutterFlow
4
4
---
5
-
5
+
# State Management
6
6
State management is a crucial concept focused on maintaining and controlling the **state** of an application. Simply put, it involves monitoring the changes within your app and updating the user interface to reflect these changes.
7
7
8
-
You can think of the UI as a function of your state variables, where changes in these variables directly influence what the UI displays.
8
+
The UI (user interface) displays information based on state variables. When these state variables change, the UI updates to reflect the changes.
9
+
10
+
## State Variables
9
11
10
12
In FlutterFlow, there are a few types of state variables that you can create:
11
13
@@ -15,27 +17,35 @@ In FlutterFlow, there are a few types of state variables that you can create:
15
17
</figure>
16
18
17
19
18
-
- State variables are themselves **variables** - meaning they have a *name* and a *data type*.
20
+
- State variables are themselves [**variables**](../../resources/data-representation/overview.md#variable) - meaning they have a *name* and a *data type*.
19
21
- They also have an initial value that is set when you create the variable.
20
22
- Once you create a state variable, it's value can be used to change the configuration of widget properties - like any other variable.
21
-
- You can update the value of state variables using the *Update State Variable* action.
23
+
- You can update the value of state variables using the **[Update State Variable](#updating-state-variables)** action.
24
+
25
+
### Creating State Variables
26
+
- To create an **App State variable**, refer to this **[guide](../../resources/data-representation/app-state.md#create-app-state-variable)**.
27
+
- To create a **Page State variable**, refer to this [**guide**](../../resources/ui-building-blocks/pages/page-lifecycle.md#creating-a-page-state).
28
+
- To create a **Component State variable**, refer to this [**guide**](../../resources/ui-building-blocks/components/user-defined-components/component-lifecycle.md#creating-a-component-state).
29
+
30
+
Note: Users cannot create **widget state variables**. These are automatically exposed by FlutterFlow when a Form widget is used.
31
+
32
+
33
+
34
+
### Updating State Variables
35
+
- To update an **App State variable**, refer to this **[guide](../../resources/data-representation/app-state.md#update-app-state-action)**.
36
+
- Refer to the [**Page Lifecycle**](../../resources/ui-building-blocks/pages/page-lifecycle.md) guide to learn about updating **[Page State variables](../../resources/ui-building-blocks/pages/page-lifecycle.md#update-page-state-action)**.
37
+
- Refer to the [**Component Lifecycle**](../../resources/ui-building-blocks/components/user-defined-components/component-lifecycle.md) guide to learn about updating **[Component State variables](../../resources/ui-building-blocks/components/user-defined-components/component-lifecycle.md#update-component-state-action)**.
22
38
39
+
<p></p>
40
+
41
+
42
+
:::tip[Learn from video]
23
43
You can learn more about state management from this video:
24
44
<divclass="video-container">
25
45
<iframesrc="https://www.youtube.com/embed/jD6L4xjYjJA?si=-RjniUB-K0ZsMoB1"title="YouTube video player"frameborder="0"allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"referrerpolicy="strict-origin-when-cross-origin"allowfullscreen></iframe>
26
46
</div>
27
-
28
-
<p></p>
29
-
30
-
:::tip
31
-
To learn more about state management in FlutterFlow, read up on
32
-
[**Variables**](../../resources/data-representation/overview.md#variable) and how
33
-
[**Page
34
-
State**](../../resources/ui-building-blocks/pages/page-lifecycle.md#page-state), or
35
-
[**Component State**](#) or [**App State variables**](#) are modified in FlutterFlow.
* In this example, we are updating the note on a bottom sheet component. To provide a better user experience, we initially display the current values of the note, ensuring that users have a clear idea of what they are going to edit. To display the note values in bottom sheet, we [pass](../../../../ff-concepts/navigation-routing/passing-data.md) the current note with **Type** set to **SQLite Row**.
218
+
* In this example, we are updating the note on a bottom sheet component. To provide a better user experience, we initially display the current values of the note, ensuring that users have a clear idea of what they are going to edit. To display the note values in bottom sheet, we [pass](../../../ff-concepts/navigation-routing/passing-data.md) the current note with **Type** set to **SQLite Row**.
219
219
220
-

220
+

221
221
222
222
* When updating a date value, we also verify if the date has been modified. If there's no change, we simply pass back the same value we received.
223
223
:::
224
224
225
225
## 7. Delete note
226
226
227
-
You can delete an existing note from the database using the [SQLite query action](../../../../resources/control-flow/backend-logic/backend-query/sqlite-query.md) with the type set to *Update Query* and Query Name to **Delete Note**.
227
+
You can delete an existing note from the database using the [SQLite query action](../../../resources/control-flow/backend-logic/backend-query/sqlite-query.md) with the type set to *Update Query* and Query Name to **Delete Note**.
228
228
229
229
:::tip[Pro Tip]
230
-
To refresh the page, simply add an [**Update App State Action**](../../../../resources/data-representation/app-state.md) Action with the Update Type set
230
+
To refresh the page, simply add an [**Update App State Action**](../../../resources/data-representation/app-state.md) Action with the Update Type set
0 commit comments