Conditional class
A content item that conditionally renders different content based on a condition.
Features:
- Dynamic content switching based on conditions
- Multiple case handling with default fallback
- Optional loading indicator during evaluation
- Support for any content type in cases
Example:
final conditional = Conditional(
condition: Condition(
configuration: ScreenSize(),
),
cases: [
CaseItem(
value: 'mobile',
item: Card(title: 'Mobile View'),
),
CaseItem(
value: 'desktop',
item: Card(title: 'Desktop View'),
),
],
defaultCase: 'mobile',
showPending: true,
);
- Inheritance
-
- Object
- ContentItem
- Conditional
- Annotations
-
- @JsonSerializable()
Constructors
-
Conditional.new({List<
CaseItem< ? cases, Condition? condition, String? defaultCase, bool showPending = false, LayoutConfiguration<SchemaItem> >ContentItem> ? layout, List<ContentModifierConfiguration> ? modifiers}) -
Conditional.fromJson(Map<
String, dynamic> json) -
factory
Properties
-
cases
→ List<
CaseItem< ?SchemaItem> > -
final
- condition → Condition?
-
final
- defaultCase → String?
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
layout
→ LayoutConfiguration<
ContentItem> ? -
The layout configuration for the content item.
finalinherited
-
modifiers
→ List<
ContentModifierConfiguration> ? -
finalinherited
- parent ↔ ContentItem?
-
The parent content item of this content item. This is used internally by the content system.
getter/setter pairinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- schemaType → String
-
The schema type of the content item.
finalinherited
- showPending → bool
-
final
Methods
-
execute(
BuildContext context) → Future< ContentItem?> -
getLayout(
) → LayoutConfiguration< ContentItem> ? -
Gets the layout to use for the
ContentItem
. By default its thelayout
itself. However this acts as an extension point for customContentItem
s that may have a different strategy for applying layouts.inherited -
getModifiers(
) → List< ContentModifierConfiguration> ? -
Gets the modifiers to use for the
ContentItem
. By default its themodifiers
itself. However this acts as an extension point for customContentItem
s that may have a different strategy for applying modifiers.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setParent(
Iterable< ContentItem?> children) → void -
Sets the parent content item for the given list of children.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
-
contentBuilder
→ ContentBuilder<
Conditional> -
final
-
typeDescriptor
→ TypeDescriptor<
Conditional> -
final
Constants
- schemaName → const String