StorytellerCardView embeds a native Storyteller Cards collection in your
Flutter layout. The native iOS and Android SDKs render the card content, while
Flutter passes configuration, analytics context, reload requests, and size
updates across the platform-view bridge.
Initialize successfully before mounting this widget and use a Cards collection containing published content for the same API key. Give the widget a finite, positive width in your Flutter layout.
classCardsSectionextendsStatefulWidget{constCardsSection({super.key});@overrideState<CardsSection>createState()=>_CardsSectionState();}class_CardsSectionStateextendsState<CardsSection>{final_controller=StorytellerCardViewController();@overridevoiddispose(){_controller.detach();super.dispose();}@overrideWidgetbuild(BuildContextcontext){returnStorytellerCardView(collectionId:'featured-cards',controller:_controller,context:const{'screen':'home_feed','placement':'feed_item',},onDataLoadComplete:(result){if(!result.success){debugPrint('Cards failed to load: ${result.error}');}},);}Future<void>refreshCards()async{await_controller.reloadData();}}
Key parameters:
collectionId - the Storyteller Cards collection to render. Supply a
non-blank value to render native Cards content.
controller - optional StorytellerCardViewController for programmatic
reloads.
initialHeight - finite, positive placeholder height until native content
reports its measured size. The default is 760.
onDataLoadComplete(StorytellerCardLoadResult result) - called when native
data loading finishes. Android also reports dataCount; iOS reports success
or failure. Error payloads include type and message, with
causeMessage when the native platform exposes an underlying cause.
The constructor keeps the older optional storyId, clipId, theme, and
onTileTapped arguments as deprecated source-compatibility shims. They do not
enable legacy card content. A StorytellerCardView without a non-blank
collectionId renders no content.
Cards can change height after native content loads. StorytellerCardView
uses a provisional height and then updates to the measured native card height. Android starts at initialHeight or a cached measurement. iOS caps the provisional height to the available width and reuses a cached measurement only at the same width.
The default is intentionally tall enough to avoid composing too many off-screen
native Card views before Android reports the measured size, while still letting
the native SDK own the final height.
reloadData() requests a native reload; its Future does not wait for onDataLoadComplete. A reload requested before the controller attaches is queued. The widget detaches its controller when disposed. Changing collectionId or context recreates the native Card view automatically; changing a deprecated argument has no effect. Use Themes for global Cards styling.
If Cards remain blank, inspect result.success and result.error, check the collection and its published content, and follow Troubleshooting. iOS does not provide a Cards count through this callback, so do not interpret a null dataCount as an empty collection.
{"slug": "cards", "page_title": "Cards", "page_url": "Cards/", "canonical_url": "/flutter/Cards/", "markdown": "# Cards\n\n`StorytellerCardView` embeds a native Storyteller Cards collection in your\nFlutter layout. The native iOS and Android SDKs render the card content, while\nFlutter passes configuration, analytics context, reload requests, and size\nupdates across the platform-view bridge.\n\nInitialize successfully before mounting this widget and use a Cards collection containing published content for the same API key. Give the widget a finite, positive width in your Flutter layout.\n\n## Basic usage\n\n```dart\nclass CardsSection extends StatefulWidget {\n const CardsSection({super.key});\n\n @override\n State<CardsSection> createState() => _CardsSectionState();\n}\n\nclass _CardsSectionState extends State<CardsSection> {\n final _controller = StorytellerCardViewController();\n\n @override\n void dispose() {\n _controller.detach();\n super.dispose();\n }\n\n @override\n Widget build(BuildContext context) {\n return StorytellerCardView(\n collectionId: 'featured-cards',\n controller: _controller,\n context: const {\n 'screen': 'home_feed',\n 'placement': 'feed_item',\n },\n onDataLoadComplete: (result) {\n if (!result.success) {\n debugPrint('Cards failed to load: ${result.error}');\n }\n },\n );\n }\n\n Future<void> refreshCards() async {\n await _controller.reloadData();\n }\n}\n```\n\nKey parameters:\n\n- `collectionId` - the Storyteller Cards collection to render. Supply a\n non-blank value to render native Cards content.\n- `context` - optional analytics attribution metadata.\n- `controller` - optional `StorytellerCardViewController` for programmatic\n reloads.\n- `initialHeight` - finite, positive placeholder height until native content\n reports its measured size. The default is `760`.\n- `onDataLoadComplete(StorytellerCardLoadResult result)` - called when native\n data loading finishes. Android also reports `dataCount`; iOS reports success\n or failure. Error payloads include `type` and `message`, with\n `causeMessage` when the native platform exposes an underlying cause.\n\n## Upgrade compatibility\n\nThe constructor keeps the older optional `storyId`, `clipId`, `theme`, and\n`onTileTapped` arguments as deprecated source-compatibility shims. They do not\nenable legacy card content. A `StorytellerCardView` without a non-blank\n`collectionId` renders no content.\n\n## Sizing behaviour\n\nCards can change height after native content loads. `StorytellerCardView`\nuses a provisional height and then updates to the measured native card height. Android starts at `initialHeight` or a cached measurement. iOS caps the provisional height to the available width and reuses a cached measurement only at the same width.\nThe default is intentionally tall enough to avoid composing too many off-screen\nnative Card views before Android reports the measured size, while still letting\nthe native SDK own the final height.\n\nFor a full feed integration, review the Showcase\n[`StorytellerCardWidget`](https://github.com/getstoryteller/storyteller-showcase-flutter/blob/main/lib/screens/home/widgets/storyteller_card_widget.dart#L5).\n\n## Reloads and configuration changes\n\n`reloadData()` requests a native reload; its `Future` does not wait for `onDataLoadComplete`. A reload requested before the controller attaches is queued. The widget detaches its controller when disposed. Changing `collectionId` or `context` recreates the native Card view automatically; changing a deprecated argument has no effect. Use [Themes](Themes.md) for global Cards styling.\n\nIf Cards remain blank, inspect `result.success` and `result.error`, check the collection and its published content, and follow [Troubleshooting](Troubleshooting.md). iOS does not provide a Cards count through this callback, so do not interpret a null `dataCount` as an empty collection.\n", "copy_markdown_include_header": false, "base_path": "", "ai_dir": "ai", "missing_payload_behavior": "empty"}