Card class

A card content item that can display various types of content in a card format.

Cards can include:

  • Title and description
  • Images (via URL or ImageReference)
  • Rich text content (PortableText)
  • Up to three actions (primary, secondary, tertiary) that can be configured with multiple action configurations

Example:

final card = Card(
  title: 'My Card',
  description: 'Card description',
  imageUrl: Uri.parse('https://example.com/image.jpg'),
  action: Action(
    configurations: [
      NavigationAction(
        linkType: LinkType.route,
        route: ObjectReference('route-id'),
      ),
      DelayAction(duration: Duration(milliseconds: 300)),
    ],
  ),
);

Cards can be used:

  • As standalone content items
  • Within groups or lists
  • Inside portable text blocks
Inheritance
Annotations
  • @JsonSerializable()

Constructors

Card.new({required String? title, required String? description, PortableTextContent? content, ImageReference? image, Uri? imageUrl, Action? action, Action? secondaryAction, Action? tertiaryAction, LayoutConfiguration<ContentItem>? layout, List<ContentModifierConfiguration>? modifiers})
Card.fromJson(Map<String, dynamic> json)
factory

Properties

action → Action?
final
blockType String
A unique string-name for the block type.
no setteroverride
content PortableTextContent?
final
description String?
final
hashCode int
The hash code for this object.
no setterinherited
image → ImageReference?
final
imageUrl Uri?
final
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
secondaryAction → Action?
final
tertiaryAction → Action?
final
title String?
final

Methods

getLayout() → LayoutConfiguration<ContentItem>?
Gets the layout to use for the ContentItem. By default its the layout itself. However this acts as an extension point for custom ContentItems that may have a different strategy for applying layouts.
inherited
getModifiers() List<ContentModifierConfiguration>?
Gets the modifiers to use for the ContentItem. By default its the modifiers itself. However this acts as an extension point for custom ContentItems 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<Card>
final
descriptor → dynamic
final
typeDescriptor → TypeDescriptor<Card>
final

Constants

schemaName → const String