The Stac Conditional allows you to conditionally render widgets based on a boolean expression. It evaluates the condition at runtime and renders either theDocumentation Index
Fetch the complete documentation index at: https://docs.stac.dev/llms.txt
Use this file to discover all available pages before exploring further.
ifTrue or ifFalse widget.
Properties
| Property | Type | Description |
|---|---|---|
| condition | String | Required. The boolean expression to evaluate at runtime. |
| ifTrue | StacWidget | Required. The widget to render when condition evaluates to true. |
| ifFalse | StacWidget | The widget to render when condition evaluates to false. Renders empty if null. |
Example
- Dart
- JSON
- Preview
Conditional with Complex Widgets
Condition Expression Syntax
Thecondition property accepts expressions that are evaluated against the current state. Common patterns include:
- Equality:
user.role == 'admin' - Boolean check:
user.isVerified == true - Comparison:
cart.total > 100 - Length check:
items.length > 0 - Null check:
user.name != null
The condition is evaluated at runtime by Stac’s expression resolver against the current application state.