Variables

🧠 Variable Types in Digia

Digia supports a wide range of variable types to help you manage input, state, and control within your app. Here's a breakdown of all supported types and their functionalities.


📦 Basic Data Types

These are commonly used to store and manage standard data:

Type
Description

String

A sequence of characters (e.g., "Hello").

Number

Represents both integers and decimals.

Boolean

true or false values.

JSON

A dynamic map-like structure.

List

An array of values, internally treated as a JSON array.


🧰 Controller Variables

These are special variable types with methods that can be invoked to control runtime behavior (e.g., scroll, pagination, form input).

Type
Description
Supported Widgets

Scroll Controller

Controls scrolling behavior of scrollable widgets.

Page Controller

Manages navigation between pages in a PageView.

Text Field Controller

Manages user input in text fields.

Stream Controller

Used to push and listen to data over time.

Async Controller

Manages async state and cache invalidation.

Timer Controller

Controls timers (start, pause, resume).


⚙️ Controller Methods

Some variable types expose runtime methods that can be invoked via actions. These methods allow advanced interaction and control over the UI or async behavior.


📜 Scroll Controller

jumpTo

Jumps to a scroll position instantly.

Argument
Description

offset

The position to scroll to, in pixels.

animateTo

Animates the scroll to a given position.

Argument
Description

offset

The position to scroll to, in pixels.

durationInMs

Animation duration in milliseconds.

curve

The easing curve to use for animation.


📖 Page Controller

jumpToPage

Instantly jumps to a specific page index.

Argument
Description

page

The target page index (zero-based).

animateToPage

Animates the page change.

Argument
Description

page

The target page index (zero-based).

durationInMs

Duration of animation in milliseconds.

curve

The easing function for page transition.

nextPage

Animates to the next page.

Argument
Description

durationInMs

Duration of animation in milliseconds.

curve

The easing function for page transition.

previousPage

Animates to the previous page.

Argument
Description

durationInMs

Duration of animation in milliseconds.

curve

The easing function for page transition.


🔄 Stream Controller

add

Emits a value to the stream.

Argument
Description

value

Any JSON-compatible value.

close

Closes the stream. (No arguments)


⏳ Async Controller

When its used with a Future Builder, rebuilds do not cause the Future Builder to get retriggered. This is especially useful if you are fetching data asynchrounously on a page but also want to rebuild the page later on.

invalidate

Forces a re-evaluation or refresh. (No arguments)


📝 Text Field Controller

setValue

Sets the field's value programmatically.

Argument
Description

text

The string to be set.

clear

Clears the text field. (No arguments)


⛔ API Cancel Token

cancel

Cancels the associated API request. (No arguments)


⏱ Timer Controller

start

Starts the timer. (No arguments)

resume

Resumes the paused timer. (No arguments)

pause

Pauses the timer. (No arguments)

reset

Resets the timer. (No arguments)


🔒 Notes

  • Only controller variables support methods.

  • Variables defined in Page State are mutable.

  • Variables defined in Page Properties are immutable and passed as arguments to the page.

Last updated