Condition class final
A conditional expression that can be evaluated at runtime.
Conditions are used to make dynamic decisions in the application based on the current state or user input. They can be used for:
- Navigation guards
- Content visibility
- Feature flags
- A/B testing
Example CMS schema:
export const condition = defineType({
name: 'condition',
fields: [
{
name: 'configuration',
type: 'reference',
to: [{type: 'condition.config'}],
},
],
});
Evaluated values select a matching conditional case, such as a platform name or a boolean string. Null means no value was produced.
- Annotations
-
- @JsonSerializable.new()
Constructors
- Condition({ConditionConfiguration? configuration})
- Creates a new condition with the given configuration.
-
Condition.fromJson(Map<
String, dynamic> json) -
Creates a condition from a JSON object.
factory
Properties
- configuration → ConditionConfiguration?
-
The configuration that defines the condition's logic.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
execute(
BuildContext context) → Future< String?> - Evaluates the condition in the current context.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited