Switch class final
Multi-branch conditional built on top of equality checks.
Cases are checked in order, and the first matching case wins. Use this when you want explicit discrete matching instead of boolean branching.
Example:
Switch(
State('status'),
cases: [
SwitchCase('draft', then: Snackbar('Draft')),
SwitchCase('published', then: Snackbar('Published')),
],
orElse: Snackbar('Unknown status'),
)
Constructors
-
Switch(Object? value, {required List<
SwitchCase> cases, Object? orElse})
Properties
-
cases
→ List<
SwitchCase> -
final
-
elseActions
→ List<
DslAction> -
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- value → DslExpression
-
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited