Flutter surveys installation
Contents
- 1
Add PostHog to your app
RequiredUsing it requires PostHog's Flutter SDK version >= 5.8.0, but it's recommended to always use the latest version.
Note: For mobile surveys, you must setup the SDK manually.
Manual installation
First, add
posthog_flutterto yourpubspec.yaml:pubspec.yamlThen complete the manual setup for each platform:
Android setup
Add your PostHog configuration to your
AndroidManifest.xmlfile located in theandroid/app/src/main:android/app/src/main/AndroidManifest.xmlYou'll also need to update the minimum Android SDK version to
21inandroid/app/build.gradle:android/app/build.gradleiOS setup
Add your PostHog configuration to the
Info.plistfile located in theios/Runnerdirectory:ios/Runner/Info.plistYou'll need to set the minimum platform version to iOS 13.0 in your Podfile:
ios/PodfileDart setup
Then setup the SDK manually:
Dart - 2
Install PosthogObserver
RequiredFor surveys to be shown, you need to add the
PosthogObserverto your app. The observer allows PostHog to determine the appropriate context for displaying surveys.DartIf you're using
go_router, check this page to learn how to set up thePosthogObserver.
Configuration
Important: For Flutter Web, surveys are powered by the JavaScript Web SDK, so any Flutter-specific survey configuration will be ignored. Please refer to the Web installation guide for proper setup.
Surveys are enabled by default. If you want to disable surveys, you can do so when setting up your SDK instance:
Supported Features
| Feature | Support |
|---|---|
| Questions | |
| All question types | ✅ |
| Multi-question surveys | ✅ |
| Confirmation message | ✅ |
| Feedback button presentation | ❌ |
| Conditional questions | ✅ |
| Customization / Appearance | |
| Set colors in PostHog dashboard | ✅ |
| Shuffle questions | ❌ |
| PostHog branding | ❌ |
| Delay popup after screen view | ❌ |
| Position config | ❌ (always bottom sheet) |
| HTML content | ❌ |
| Display conditions | |
| Feature flag & property targeting | ✅ |
| Screen/URL targeting | ❌ |
| Device type targeting | ✅ |
| Survey wait period | ❌ |
| Event triggers | ✅ |
| Action triggers | ❌ |
| Partial responses | ❌ |
Limitations
- On Android, requires API >= 26.
- On iOS, minimum deployment target is iOS13.
- On Web, surveys are powered by the JavaScript Web SDK.
- Requires PostHog Flutter SDK version >= 5.8.0
Troubleshooting
- Update your SDK and iOS Pods.
- Make sure to set the minimum platform version to iOS 13.0 in your Podfile.
- Make sure you have disabled automatic SDK initialization.
- Run a clean build if you experience issues.
- If surveys are not being displayed when triggered, make sure you have installed the PosthogObserver.
- Using navigationObservers
- Using go_router
- If you are using multiple navigation observers and encounter a log message
[PostHog] Cannot show survey: No valid context found..., try placingPosthogObserverfirst in the list of observers. We've noticed that order sometimes matters due to potential interference.