Variables
Variables in Digia allow you to store and manage data throughout your app. They come in two main categories: Basic Data Types for storing standard values, and Controller Types for controlling widget behavior and runtime interactions.
📦 Basic Data Types
Basic data types store standard values like text, numbers, and structured data.
🧰 Controller Types
Controller types are special variables with methods that control widget behavior at runtime. Use the Control Object action to invoke their methods.
Scroll Controller
Controls scrolling behavior
ListView, GridView, Smart Scroll View, Animation Builder
� Variable Scope
Variables can be defined in different scopes depending on where you need to use them:
Page State
Variables defined in Page State are:
Mutable (can be changed)
Scoped to the current page
Reset when navigating away from the page
Ideal for temporary UI state, form data, or page-specific logic
Page Properties
Variables defined in Page Properties are:
Immutable (read-only)
Passed as arguments when navigating to the page
Used to pass data between pages
Ideal for IDs, configuration, or data from previous pages
App State
Variables defined in App State are:
Mutable (can be changed)
Global across the entire app
Persist across page navigation
Ideal for user data, authentication state, or app-wide settings
🎯 Best Practices
Use appropriate types: Choose the simplest type that fits your data (String for text, Boolean for toggles, etc.)
Name descriptively: Use clear, descriptive names (
userNameinstead ofu1)Initialize with defaults: Always set initial values to avoid null/undefined errors
Scope appropriately: Use Page State for temporary data, App State for persistent data
One controller per widget: Each controllable widget should have its own controller variable
Clean up controllers: Close streams and clean up controllers when no longer needed
Related Documentation
Setting State - How to update variable values
Control Object - Invoking controller methods
Expressions and Operators - Using variables in logic
API Calls - Storing API response data in variables
Last updated