The code samples below show how to use the StorytellerHomeView widget in Flutter. The component includes built-in pull-to-refresh support on both iOS and Android platforms, and you can also use the controller's reloadData() method to refresh data programmatically.
Create a StorytellerHomeView widget by passing the required homeId parameter. The widget accepts the following parameters:
homeId - (required) an identifier of the home configuration you want to load.
theme - an optional theme parameter to be used for styling. If no theme is supplied, the global theme set via Storyteller.setTheme(...) is used.
uiStyle - an optional parameter for overriding the appearance of the component. Possible values are 'light', 'dark', and 'auto'. The default styling is 'auto' and it uses the system setting value.
context - optional context data that will be included in analytics callbacks for attribution. This allows you to track which sources drive engagement with your home content. See Analytics for more details.
controller - an optional StorytellerHomeViewController for programmatic control of the view.
import'package:flutter/material.dart';import'package:storyteller_sdk/storyteller_sdk.dart';classMyHomePageextendsStatefulWidget{constMyHomePage({Key?key}):super(key:key);@overrideState<MyHomePage>createState()=>_MyHomePageState();}class_MyHomePageStateextendsState<MyHomePage>{finalStorytellerHomeViewController_controller=StorytellerHomeViewController();@overridevoiddispose(){_controller.detach();super.dispose();}void_refreshContent(){// Programmatically refresh the home content_controller.reloadData();}@overrideWidgetbuild(BuildContextcontext){// Create a custom themefinaltheme=StorytellerTheme(// Customize the themelight:ThemeType(// Add your theme settingslists:ThemeLists(backgroundColor:'#FFFFFF',),),);returnScaffold(appBar:AppBar(title:constText('Storyteller Home'),actions:[IconButton(icon:constIcon(Icons.refresh),onPressed:_refreshContent,),],),body:StorytellerHomeView(homeId:'YOUR_HOME_ID',controller:_controller,theme:theme,uiStyle:'auto',context:{'source':'main-tab','user_segment':'premium','variant':'personalized',},),);}}
For a live reference, the Showcase account tab renders this widget in StorytellerHomeScreen with an on-screen homeId picker and manual reload actions.
{"slug": "storyteller-home", "page_title": "Home Component", "page_url": "StorytellerHome/", "canonical_url": "/flutter/StorytellerHome/", "markdown": "# Storyteller Home Component\n\n`StorytellerHomeView` is a widget that allows multiple Stories and Clips Rows or Grids to be embedded in a single screen in your application in a list.\n\n## How to Use\n\nThe code samples below show how to use the `StorytellerHomeView` widget in Flutter. The component includes built-in pull-to-refresh support on both iOS and Android platforms, and you can also use the controller's `reloadData()` method to refresh data programmatically.\n\n### Basic Usage\n\nCreate a `StorytellerHomeView` widget by passing the required `homeId` parameter. The widget accepts the following parameters:\n\n- `homeId` - (required) an identifier of the home configuration you want to load.\n- `theme` - an optional theme parameter to be used for styling. If no theme is supplied, the global theme set via `Storyteller.setTheme(...)` is used.\n- `uiStyle` - an optional parameter for overriding the appearance of the component. Possible values are `'light'`, `'dark'`, and `'auto'`. The default styling is `'auto'` and it uses the system setting value.\n- `context` - optional context data that will be included in analytics callbacks for attribution. This allows you to track which sources drive engagement with your home content. See [Analytics](Analytics.md) for more details.\n- `controller` - an optional `StorytellerHomeViewController` for programmatic control of the view.\n\n```dart\nimport 'package:flutter/material.dart';\nimport 'package:storyteller_sdk/storyteller_sdk.dart';\n\nclass MyHomePage extends StatefulWidget {\n const MyHomePage({Key? key}) : super(key: key);\n\n @override\n State<MyHomePage> createState() => _MyHomePageState();\n}\n\nclass _MyHomePageState extends State<MyHomePage> {\n final StorytellerHomeViewController _controller = StorytellerHomeViewController();\n\n @override\n void dispose() {\n _controller.detach();\n super.dispose();\n }\n\n void _refreshContent() {\n // Programmatically refresh the home content\n _controller.reloadData();\n }\n\n @override\n Widget build(BuildContext context) {\n // Create a custom theme\n final theme = StorytellerTheme(\n // Customize the theme\n light: ThemeType(\n // Add your theme settings\n lists: ThemeLists(\n backgroundColor: '#FFFFFF',\n ),\n ),\n );\n\n return Scaffold(\n appBar: AppBar(\n title: const Text('Storyteller Home'),\n actions: [\n IconButton(\n icon: const Icon(Icons.refresh),\n onPressed: _refreshContent,\n ),\n ],\n ),\n body: StorytellerHomeView(\n homeId: 'YOUR_HOME_ID',\n controller: _controller,\n theme: theme,\n uiStyle: 'auto',\n context: {\n 'source': 'main-tab',\n 'user_segment': 'premium',\n 'variant': 'personalized',\n },\n ),\n );\n }\n}\n\n```\n\nFor a live reference, the Showcase account tab renders this widget in [`StorytellerHomeScreen`](https://github.com/getstoryteller/storyteller-showcase-flutter/blob/main/lib/screens/account/storyteller_home_screen.dart#L147) with an on-screen `homeId` picker and manual reload actions.\n", "copy_markdown_include_header": false, "base_path": "", "ai_dir": "ai", "missing_payload_behavior": "empty"}