The Search component allows users to search for Storyteller Clips and Stories. As users type, a list of suggestions will appear, from which users can either select a suggestion or search using their entered term. Results are categorized into two sections: Stories and Clips, based on their type. Filters allow users to narrow down their search results, enabling them to find specific content that meets their criteria more efficiently. For instance, users can apply filters such as date posted, content type or they can sort it by certain criteria.
The Search feature must first be enabled by the Storyteller team for your specific tenant. Once enabled, the Search functionality will be available within the Story and Clip players.
Additional Search functionality is available through the Storyteller class:
Use openSearch() to open the Search component from anywhere in the app. If Storyteller player is currently displayed, it will be dismissed before presenting the Search component.
// Open search from anywhere in your appawaitStoryteller.openSearch();
Example: Adding a Search Button
import'package:flutter/material.dart';import'package:storyteller_sdk/storyteller_sdk.dart';classSearchButtonextendsStatelessWidget{@overrideWidgetbuild(BuildContextcontext){returnFutureBuilder<bool>(future:Storyteller.isSearchEnabled(),builder:(context,snapshot){if(!snapshot.hasData||!snapshot.data!){returnSizedBox.shrink();// Hide button if search is disabled}returnIconButton(icon:Icon(Icons.search),onPressed:()async{awaitStoryteller.openSearch();},);},);}}
{"slug": "search", "page_title": "Search", "page_url": "Search/", "canonical_url": "/flutter/Search/", "markdown": "# Search\n\nThe `Search` component allows users to search for Storyteller Clips and Stories. As users type, a list of suggestions will appear, from which users can either select a suggestion or search using their entered term. Results are categorized into two sections: `Stories` and `Clips`, based on their type. Filters allow users to narrow down their search results, enabling them to find specific content that meets their criteria more efficiently. For instance, users can apply filters such as date posted, content type or they can sort it by certain criteria.\n\n## Search Filters\n\n`Date Posted` possible values:\n\n- `All` - default value\n- `Past 24 hours`\n- `Last Week`\n- `Last Month`\n- `Last Year`\n\n`Content Type` possible values:\n\n- `All` - default value\n- `Stories`\n- `Clips`\n\n`Sort By` values:\n\n- `Relevance` - default value\n- `Like Count`\n- `Share Count`\n- `Date Posted`\n\n## How to Use\n\nThe `Search` feature must first be enabled by the Storyteller team for your specific tenant. Once enabled, the Search functionality will be available within the Story and Clip players.\n\nAdditional `Search` functionality is available through the `Storyteller` class:\n\n### Check if Search is Enabled\n\nUse `isSearchEnabled()` to check whether search functionality is enabled at the app level.\n\n```dart\nfinal isEnabled = await Storyteller.isSearchEnabled();\nif (isEnabled) {\n print('Search is enabled');\n} else {\n print('Search is not enabled');\n}\n```\n\n### Open Search\n\nUse `openSearch()` to open the `Search` component from anywhere in the app. If Storyteller player is currently displayed, it will be dismissed before presenting the `Search` component.\n\n```dart\n// Open search from anywhere in your app\nawait Storyteller.openSearch();\n```\n\n**Example: Adding a Search Button**\n\n```dart\nimport 'package:flutter/material.dart';\nimport 'package:storyteller_sdk/storyteller_sdk.dart';\n\nclass SearchButton extends StatelessWidget {\n @override\n Widget build(BuildContext context) {\n return FutureBuilder<bool>(\n future: Storyteller.isSearchEnabled(),\n builder: (context, snapshot) {\n if (!snapshot.hasData || !snapshot.data!) {\n return SizedBox.shrink(); // Hide button if search is disabled\n }\n \n return IconButton(\n icon: Icon(Icons.search),\n onPressed: () async {\n await Storyteller.openSearch();\n },\n );\n },\n );\n }\n}\n```\n\nThe Showcase home screen wires these APIs end-to-end: `initState` queries availability via [`Storyteller.isSearchEnabled()`](https://github.com/getstoryteller/storyteller-showcase-flutter/blob/main/lib/screens/home/home_screen.dart#L32) and the search icon triggers [`Storyteller.openSearch()`](https://github.com/getstoryteller/storyteller-showcase-flutter/blob/main/lib/screens/home/home_screen.dart#L88).\n\n## Customization\n\nCertain UI parts of the `Search` component can be customized through theming. For more information, see the [Themes documentation - Search section](Themes.md#search).\n\nYou can customize:\n\n- Back icon\n- Filter heading font, size, line height, text case, and color\n\n**Example: Customizing Search Appearance**\n\n```dart\nfinal theme = StorytellerTheme(\n light: ThemeType(\n search: ThemeSearch(\n backIcon: ThemeImage(filePath: 'assets/icons/custom_back.png'),\n heading: ThemeTitle(\n textSize: 24.0,\n lineHeight: 30.0,\n textCase: 'upper',\n textColor: '#000000',\n ),\n ),\n ),\n);\n\nawait Storyteller.setTheme(theme);\n```\n", "copy_markdown_include_header": false, "base_path": "", "ai_dir": "ai", "missing_payload_behavior": "empty"}