Flutter surveys installation
- 1
Install the package
RequiredAdd the PostHog Flutter SDK to your
pubspec.yaml:pubspec.yaml - 2
Platform setup
RequiredAdd these values to your
AndroidManifest.xml:android/app/src/main/AndroidManifest.xmlUpdate the minimum Android SDK version to 21 in
android/app/build.gradle:android/app/build.gradleAdd these values to your
Info.plist:ios/Runner/Info.plistUpdate the minimum platform version to iOS 13.0 in your
Podfile:PodfileAdd these values in
index.html:web/index.html - 3
Send events
RecommendedOnce installed, PostHog will automatically start capturing events. You can also manually send events to test your integration:
Dart - 4
Install PosthogObserver
RequiredFor surveys to be shown, you need to add the PosthogObserver to your app. The observer allows PostHog to determine the appropriate context for displaying surveys.
main.dartIf you're using go_router, check this page to learn how to set up the PosthogObserver.
- 5
Configuration
OptionalImportant: 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:
main.dart - 6
Next steps
RecommendedAfter installing the PostHog SDK, you can create your first survey.
Resource Description Creating surveys Learn how to build and customize your surveys Targeting surveys Show surveys to specific users based on properties, events, or feature flags How to create custom surveys Build advanced survey experiences with custom code Framework guides Setup guides for React, Next.js, Vue, and other frameworks More tutorials Other real-world examples and use cases You should also identify users and capture events with PostHog to control who and when to show surveys to your users.
Not all survey features are available on every SDK. See the SDK feature support matrix for a full comparison.
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 (5.14.0+ recommended for latest features)
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.