Initialize Storyteller as early as possible (typically in main() before runApp). Provide your API key and optionally an externalId that maps to your user record.
import'package:flutter/widgets.dart';import'package:storyteller_sdk/storyteller_sdk.dart';Future<void>main()async{WidgetsFlutterBinding.ensureInitialized();finalresult=awaitStoryteller.initialize('YOUR_API_KEY',externalId:'YOUR_USER_ID',// optional);if(!result.success){// Initialization failed. The message is a human-readable description.// You can also report this to your logging/analytics system.throwException(result.message??'Storyteller initialization failed');}runApp(constMyApp());}
If you need privacy controls, configure StorytellerEventTrackingOptions during initialization (see Privacy and Tracking).
Compare this to the Showcase bootstrap in lib/main.dart, which initializes storage, the deep-link service, and then restores the SDK session before runApp.
{"slug": "getting-started-index", "page_title": "Quickstart Guide", "page_url": "getting-started/", "canonical_url": "/flutter/getting-started/", "markdown": "# Quickstart Guide\n\nThis guide walks through the basic Flutter integration steps:\n\n1. Add the `storyteller_sdk` dependency\n2. Initialize the SDK with your API key (and optional user identifier)\n3. Render a Storyteller widget in your UI\n\n## Prerequisites\n\n- A Storyteller API key (provided by the Storyteller team)\n- Platform support:\n - iOS 13.0+\n - Android API 24+\n\n## 1) Install the SDK\n\nAdd the dependency to your app's `pubspec.yaml`:\n\n```yaml\ndependencies:\n storyteller_sdk: ^11.6.5\n```\n\nThen fetch packages:\n\n```bash\nflutter pub get\n```\n\nFor iOS, add both Storyteller CocoaPods sources above the CocoaPods CDN in the\napp's `ios/Podfile`:\n\n```ruby\nsource 'https://github.com/getstoryteller/storyteller-sdk-ios-podspec.git'\nsource 'https://github.com/getstoryteller/storyteller-lottie-ios-podspec.git'\nsource 'https://cdn.cocoapods.org/'\n```\n\n## 2) Initialize Storyteller\n\nInitialize Storyteller as early as possible (typically in `main()` before `runApp`). Provide your API key and optionally an `externalId` that maps to your user record.\n\n```dart\nimport 'package:flutter/widgets.dart';\nimport 'package:storyteller_sdk/storyteller_sdk.dart';\n\nFuture<void> main() async {\n WidgetsFlutterBinding.ensureInitialized();\n\n final result = await Storyteller.initialize(\n 'YOUR_API_KEY',\n externalId: 'YOUR_USER_ID', // optional\n );\n\n if (!result.success) {\n // Initialization failed. The message is a human-readable description.\n // You can also report this to your logging/analytics system.\n throw Exception(result.message ?? 'Storyteller initialization failed');\n }\n\n runApp(const MyApp());\n}\n```\n\nNext:\n\n- If you use `externalId`, read [Working with Users](../Users.md) for user-related APIs.\n- If you need privacy controls, configure `StorytellerEventTrackingOptions` during initialization (see [Privacy and Tracking](../PrivacyAndTracking.md)).\n\nCompare this to the Showcase bootstrap in [`lib/main.dart`](https://github.com/getstoryteller/storyteller-showcase-flutter/blob/main/lib/main.dart#L12), which initializes storage, the deep-link service, and then restores the SDK session before `runApp`.\n\n## 3) Render a Storyteller widget\n\nStoryteller provides multiple widgets for displaying Stories and Clips. A common starting point is a stories row:\n\n```dart\nimport 'package:flutter/widgets.dart';\nimport 'package:storyteller_sdk/storyteller_sdk.dart';\n\nclass StoriesSection extends StatelessWidget {\n const StoriesSection({super.key});\n\n @override\n Widget build(BuildContext context) {\n return const SizedBox(\n height: 320,\n child: StorytellerStoriesRowView(\n // Optional: pass categories configured in Storyteller\n // categories: ['news', 'sports'],\n ),\n );\n }\n}\n```\n\nSee [List Components](../StorytellerListViews.md) for grids, clips lists, callbacks, and `StorytellerListViewController`.\n\n## Next steps\n\n- **UI customization:** [Themes](../Themes.md)\n- **Events & analytics:** [Analytics](../Analytics.md) and [Event Streams](../StorytellerDelegate.md)\n- **Deep links and navigation back to your app:** [Deep Linking](../Deeplinking.md)\n- **Ads (including GAM integration):** [Ads](../Ads.md)\n", "copy_markdown_include_header": false, "base_path": "", "ai_dir": "ai", "missing_payload_behavior": "empty"}