Flutter Feature Flags installation
Install with the wizard
Run this command in your project directory to add PostHog to your Flutter project. The wizard detects your framework, installs the SDK, and sets up your first events.
Or set it up manually by following the rest of this guide.
CocoaPods is becoming read-only. CocoaPods trunk becomes read-only on December 2, 2026, and
posthog-ios4.0 and later is only published through Swift Package Manager (SPM).
posthog_flutter6.0 and later usesposthog-ios4.0 and installs on iOS and macOS through SPM only. It has no podspec. It needs Xcode 26 or later, iOS 15, and macOS 12. Flutter 3.44 and later turn SPM on by default. See the Flutter migration guide.
posthog_flutter5.x stays onposthog-ios3.x through CocoaPods or SPM. If your app can't use SPM, stay on 5.x. That includes a Flutter module embedded in an iOS app on Flutter earlier than 3.50, which installs module plugins with CocoaPods.
posthog_flutter6.0 also needs Flutter 3.41 or later on every platform, including Android and web.flutter pub getfails on an older Flutter.
- 1
Install the package
RequiredAdd the PostHog Flutter SDK to your
pubspec.yaml:pubspec.yamlposthog_flutter 6.0requires Flutter 3.41 or later on every platform.If you embed Flutter in an iOS app as a module (
flutter create -t module), use Flutter 3.50 or later and build it withflutter build swift-package. Earlier Flutter versions install module plugins with CocoaPods, andposthog_flutter6.0 has no podspec, so stay onposthog_flutter5.x there. - 2
Platform setup
RequiredAdd these values to your
AndroidManifest.xml:android/app/src/main/AndroidManifest.xmlposthog_flutter needs a minimum Android SDK version of 23 or higher. New Flutter projects default to 24, so change
android/app/build.gradleonly if your app sets a lower value:android/app/build.gradleAdd these values to your
Info.plist:ios/Runner/Info.plistiOS and macOS builds require Xcode 26 or later. Set the minimum deployment target to iOS 15.0, or macOS 12.0 for a macOS app, in Xcode (Runner > General > Minimum Deployments). PostHog installs through Swift Package Manager, which is on by default from Flutter 3.44. On Flutter 3.41 to 3.43, or if you turned it off, run
flutter config --enable-swift-package-manager. If you keep aPodfilefor other plugins, setplatform :ios, '15.0'there too (platform :osx, '12.0'inmacos/Podfile), then runflutter build ios --config-only(orflutter build macos --config-only).Add 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
Evaluate boolean feature flags
RequiredCheck if a feature flag is enabled:
Dart - 5
Evaluate multivariate feature flags
OptionalFor multivariate flags, check which variant the user has been assigned:
Dart - 6
Running experiments
OptionalExperiments run on top of our feature flags. Once you've implemented the flag in your code, you run an experiment by creating a new experiment in the PostHog dashboard.
- 7
Next steps
RecommendedNow that you're evaluating flags, continue with the resources below to learn what else Feature Flags enables within the PostHog platform.
Resource Description Creating a feature flag How to create a feature flag in PostHog Adding feature flag code How to check flags in your code for all platforms Framework-specific guides Setup guides for React Native, Next.js, Flutter, and other frameworks How to do a phased rollout Gradually roll out features to minimize risk More tutorials Other real-world examples and use cases





