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/generated-code/pages-generated-code.md
+50-24Lines changed: 50 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -91,37 +91,40 @@ Finally, the `dispose` function in the `ProductListPageModel` class is used to c
91
91
The `PageWidget` classes are responsible for creating the UI of individual pages and holding the widget tree as designed in the FlutterFlow canvas. These classes always extend Flutter's `StatefulWidget` class utilizing Flutter's built-in state management through `setState` to handle dynamic updates and interact with the app's lifecycle.
In the generated code, FlutterFlow automatically includes the `RouteAware` mixin in the **State** class. This makes the page aware of changes in the navigator's session history, allowing it to handle lifecycle events such as when the page becomes visible again after being removed.
103
+
#### PageModel Initialization
104
+
Within the State class, the `PageModel` object is initialized. [This class](#pagemodel-class) serves as a centralized place to manage the page’s state, handle business logic, and interact with the data layer.
Additionally, the `PageModel` class is initialized within the state class. This class serves as a centralized place to manage the page’s state, handle business logic, and interact with the data layer.
119
+
#### PageModel Dispose
120
+
Similarly, the [`dispose` method](#dispose) of the `PageModel` class is invoked from the **overridden** `dispose` method of the widget's **State** class. This ensures that any resources managed by the `PageModel`, such as listeners or controllers, are properly released when the widget is removed from the widget tree.
Moreover, the root widget of every page is a `GestureDetector` with an `onTap` callback that unfocuses the current input field. This ensures that any active keyboard is dismissed when tapping outside an input field, improving the user experience across pages.
142
+
Moreover, the root widget of every page is a `GestureDetector` with an `onTap` callback that unfocuses the current input field. This approach ensures that tapping anywhere outside an input field dismisses the keyboard or removes focus, creating a better user experience.
140
143
141
144
```js
142
145
returnGestureDetector(
143
-
onTap: () =>FocusScope.of(context).unfocus(),
144
-
child:Scaffold(
145
-
...)
146
+
onTap: () {
147
+
FocusScope.of(context).unfocus();
148
+
FocusManager.instance.primaryFocus?.unfocus();
149
+
},
150
+
...)
146
151
```
147
152
148
153
These functionalities are automatically added by FlutterFlow to ensure seamless navigation and proper keyboard handling across pages.
149
154
155
+
### onPageLoad Action: Generated Code
156
+
157
+
When you define actions for the `onPageLoad` action trigger of a Page, these actions are added inside an `addPostFrameCallback` method within the page's `initState` method. This ensures that the actions are executed only after the initial widget tree is built.
The `addPostFrameCallback` ensures that onPageLoad actions are executed after the widget is fully built and rendered. This avoids issues caused by trying to update the UI before it is ready.
When you add actions to the **on Page Load** action trigger, they are executed within a `SchedulerBinding.instance.addPostFrameCallback((_)` method. This ensures that the actions run after the widget tree is fully built. For more details, refer to the [**Page: Generated Code**](../../../generated-code/pages-generated-code.md#onpageload-action-generated-code) document.
79
+
:::
80
+
77
81
### On Phone Shake [Action Trigger]
78
82
79
83
Actions added under this trigger are triggered when the
0 commit comments