StacConditional class

A Stac model representing a conditional widget.

Evaluates a boolean expression in condition and renders either ifTrue or ifFalse. If ifFalse is not provided and the condition evaluates to false, an empty widget will be rendered by the parser.

{@tool snippet} Dart Example:

StacConditional(
  condition: "user.isLoggedIn == true",
  ifTrue: StacText(data: 'Welcome back!'),
  ifFalse: StacText(data: 'Please sign in'),
)

{@end-tool}

{@tool snippet} JSON Example:

{
  "type": "conditional",
  "condition": "user.isLoggedIn == true",
  "ifTrue": { "type": "text", "data": "Welcome back!" },
  "ifFalse": { "type": "text", "data": "Please sign in" }
}

{@end-tool}

Inheritance
Annotations
  • @JsonSerializable.new()

Constructors

StacConditional({required String condition, required StacWidget ifTrue, StacWidget? ifFalse})
Creates a StacConditional.
const
StacConditional.fromJson(Map<String, dynamic> json)
Creates a StacConditional from a JSON map.
factory

Properties

condition → String
The boolean expression to evaluate.
final
hashCode → int
The hash code for this object.
no setterinherited
ifFalse → StacWidget?
The widget to render when condition evaluates to false. If null, the parser will render an empty widget.
final
ifTrue → StacWidget
The widget to render when condition evaluates to true.
final
jsonData → Map<String, dynamic>?
Raw JSON data for this widget
finalinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
type → String
Widget type identifier.
no setteroverride

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() → Map<String, dynamic>
Converts this StacConditional instance to a JSON map.
override
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited