Variables
Variables in Digia allow you to store and manage data throughout your app. They come in three main categories: Basic Data Types for storing standard values, Controller Types for controlling widget behavior and runtime interactions, and Action Types for storing executable action flows.
📦 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
Entity Variables, Entity Params, State Container Variables
Page Controller
Manages page navigation in PageView
PageView, Animation Builder
Entity Variables, Entity Params, State Container Variables
Text Field Controller
Manages text input fields
Text Form Field
Entity Variables, Entity Params, State Container Variables
Stream Controller
Pushes and listens to data streams
Stream Builder
Entity Variables, Entity Params, State Container Variables
Async Controller
Manages async state and cache invalidation
Future Builder
Entity Variables, Entity Params, State Container Variables
Timer Controller
Controls timer operations
Timer
Entity Variables, Entity Params, State Container Variables
⚡ Action Types
Action types store executable action flows that can be invoked dynamically. Use the Execute Callback action to run stored actions.
Action
Stores an ActionFlow that can be executed later
Component callbacks, dynamic event handlers, reusable action sequences
Entity Params (components only)
� Variable Scope
Variables can be defined in different scopes depending on where you need to use them. Each scope supports different variable types:
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
Supported Types: String, Number, Boolean, JSON, List (JSON Array)
App State uses DUIAppState for reactive state management with optional persistence.
Entity Params
Variables defined in Entity Params are:
Immutable (read-only)
Passed as arguments when navigating to pages or instantiating components
Used to pass data between pages or configure component behavior
Supported Types: All types (String, Number, Boolean, JSON, List, Controllers, Action*)
Note: Action variables are supported in component params but not in page params.
Entity Variables
Variables defined in Entity Variables (Page State/Component State) are:
Mutable (can be changed)
Scoped to the current page or component
Reset when navigating away or when component unmounts
Ideal for temporary UI state, form data, or component-specific logic
Supported Types: All types except Action variables (String, Number, Boolean, JSON, List, Controllers)
State Container Variables
Variables defined in State Container Variables are:
Mutable (can be changed)
Scoped to a specific state container widget
Reset when the container is destroyed
Ideal for managing state within complex UI sections
Supported Types: All types except Action variables (String, Number, Boolean, JSON, List, Controllers)
Note: Parameters of Action variables cannot be of type Action.
🎯 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
Choose correct scope: Use App State for global data, Entity Variables for local state, Entity Params for configuration
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
Action variables for callbacks: Use Action type variables to store reusable action flows for component communication
Respect type limitations: Action variables are not supported in App State, Entity Variables, or State Container Variables
Related Documentation
DUIAppState - Complete guide to global app state management
Setting State - How to update variable values
Control Object - Invoking controller methods
Execute Callback - Running stored action flows
Expressions and Operators - Using variables in logic
API Calls - Storing API response data in variables
Last updated