Generated banner for Feature Flags Flutter
Generated logo for Feature Flags Flutter

Feature Flags Flutter

PostHogOfficialCreated by PostHog

  • Skill
  • Tool integration
  • Data and AI
  • MIT
  • No issues found

From the author

PostHog feature flags for Flutter applications
— the description by PostHog

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides guidance and best practices for implementing PostHog feature flags within Flutter applications. It covers the integration process, recommended coding patterns to minimize technical debt, and strategies for ensuring consistent user experiences across sessions. The skill emphasizes efficient flag management, including the use of environment variables for security and server-side evaluation to optimize performance and reduce UI flicker.

What it does

  • Provides instructions for integrating PostHog feature flags into Flutter projects.
  • Outlines best practices for flag naming and organization to maintain code clarity.
  • Offers guidance on using server-side evaluation to improve application performance.
  • Explains how to manage flag dependencies and user properties for consistent targeting.
  • Supports the use of PostHog MCP tools for direct flag management within the development environment.

When to use it

  • When you need to perform controlled feature rollouts or A/B testing in a Flutter app.
  • When you want to decouple feature releases from code deployments.
  • When you need to manage user-specific feature access or permissions dynamically.
  • When you are setting up a new Flutter project and want to incorporate experimentation capabilities.

Advantages

  • Reduces the risk of deploying new features by allowing instant toggling.
  • Improves application performance through local evaluation and efficient flag handling.
  • Enhances code maintainability by promoting clean, centralized flag management patterns.
  • Ensures consistent user experiences by leveraging proper identification and targeting strategies.

Usage examples

“How do I check if a feature flag is enabled in my Flutter app?”
The agent provides the code pattern for checking a boolean flag using the PostHog SDK, ensuring the check is integrated cleanly into your existing logic.
“What is the best way to name my feature flags?”
The agent suggests using descriptive, type-prefixed names like 'is_premium_user' or 'new-billing-experiment' to keep your dashboard organized and your code readable.

Install

  1. Download the skill as a ZIP:

    https://mp-staging.autogineer.com/agent-skills/posthog/feature-flags-flutter/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip feature-flags-flutter.zip -d .agents/skills

Documentation by PostHog

PostHog feature flags for Flutter

This skill helps you add PostHog feature flags to Flutter applications.

Reference files

  • references/flutter.md - Flutter feature flags installation - docs

  • references/adding-feature-flag-code.md - Adding feature flag code - docs

  • references/best-practices.md - Feature flag best practices - docs

Consult the documentation for API details and framework-specific patterns.

Key principles

  • Environment variables: Always use environment variables for PostHog keys. Never hardcode them.

  • Minimal changes: Add feature flag code alongside existing logic. Don't replace or restructure existing code.

  • Boolean flags first: Default to boolean flag checks unless the user specifically asks for multivariate flags.

  • Server-side when possible: Prefer server-side flag evaluation to avoid UI flicker.

PostHog MCP tools

Check if a PostHog MCP server is connected. If available, look for tools related to feature flag management (creating, listing, updating, deleting flags). Use these tools to manage flags directly in PostHog rather than requiring the user to do it manually in the dashboard.

Framework guidelines

No specific framework guidelines.

Files

references/flutter.md

Flutter feature flags installation - Docs

  1. 1

    Install the package

    Required

    Add the PostHog Flutter SDK to your pubspec.yaml:

    pubspec.yaml

    PostHog AI

    posthog_flutter: ^5.0.0
  2. 2

    Platform setup

    Required

    Tab

    Add these values to your AndroidManifest.xml:

    android/app/src/main/AndroidManifest.xml

    PostHog AI

    <application>
      <activity>
        [...]
      </activity>
      <meta-data android:name="com.posthog.posthog.API_KEY" android:value="<ph_project_token>" />
      <meta-data android:name="com.posthog.posthog.POSTHOG_HOST" android:value="https://us.i.posthog.com" />
      <meta-data android:name="com.posthog.posthog.TRACK_APPLICATION_LIFECYCLE_EVENTS" android:value="true" />
      <meta-data android:name="com.posthog.posthog.DEBUG" android:value="true" />
    </application>

    Update the minimum Android SDK version to 21 in android/app/build.gradle:

    android/app/build.gradle

    PostHog AI

    defaultConfig {
      minSdkVersion 21
      // rest of your config
    }

    Tab

    Add these values to your Info.plist:

    ios/Runner/Info.plist

    PostHog AI

    <dict>
      [...]
      <key>com.posthog.posthog.API_KEY</key>
      <string><ph_project_token></string>
      <key>com.posthog.posthog.POSTHOG_HOST</key>
      <string>https://us.i.posthog.com</string>
      <key>com.posthog.posthog.CAPTURE_APPLICATION_LIFECYCLE_EVENTS</key>
      <true/>
      <key>com.posthog.posthog.DEBUG</key>
      <true/>
    </dict>

    Update the minimum platform version to iOS 13.0 in your Podfile:

    Podfile

    PostHog AI

    platform :ios, '13.0'
    # rest of your config

    Tab

    Add these values in index.html:

    web/index.html

    PostHog AI

    <!DOCTYPE html>
    <html>
      <head>
        ...
        <script>
          !function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host.replace(".i.posthog.com","-assets.i.posthog.com")+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="init capture register register_once register_for_session unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group identify setPersonProperties setPersonPropertiesForFlags resetPersonPropertiesForFlags setGroupPropertiesForFlags resetGroupPropertiesForFlags resetGroups onFeatureFlags addFeatureFlagsHandler onSessionId getSurveys getActiveMatchingSurveys renderSurvey canRenderSurvey getNextSurveyStep".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
          posthog.init('<ph_project_token>', {
              api_host: 'https://us.i.posthog.com',
              defaults: '2026-01-30',
          })
        </script>
      </head>
      <body>
        ...
      </body>
    </html>
  3. 3

    Send events

    Recommended

    Once installed, PostHog will automatically start capturing events. You can also manually send events to test your integration:

    Dart

    PostHog AI

    import 'package:posthog_flutter/posthog_flutter.dart';
    await Posthog().capture(
        eventName: 'button_clicked',
        properties: {
          'button_name': 'signup'
        }
    );
  4. 4

    Evaluate boolean feature flags

    Required

    Check if a feature flag is enabled:

    Dart

    PostHog AI

    final isMyFlagEnabled = await Posthog().isFeatureEnabled('flag-key');
    if (isMyFlagEnabled) {
        // Do something differently for this user
        // Optional: fetch the payload
        final matchedFlagPayload = await Posthog().getFeatureFlagPayload('flag-key');
    }
  5. 5

    Evaluate multivariate feature flags

    Optional

    For multivariate flags, check which variant the user has been assigned:

    Dart

    PostHog AI

    final enabledVariant = await Posthog().getFeatureFlag('flag-key');
    if (enabledVariant == 'variant-key') { // replace 'variant-key' with the key of your variant
        // Do something differently for this user
        // Optional: fetch the payload
        final matchedFlagPayload = await Posthog().getFeatureFlagPayload('flag-key');
    }
  6. 6

    Running experiments

    Optional

    Experiments 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. 7

    Next steps

    Recommended

    Now that you're evaluating flags, continue with the resources below to learn what else Feature Flags enables within the PostHog platform.

    ResourceDescription
    Creating a feature flagHow to create a feature flag in PostHog
    Adding feature flag codeHow to check flags in your code for all platforms
    Framework-specific guidesSetup guides for React Native, Next.js, Flutter, and other frameworks
    How to do a phased rolloutGradually roll out features to minimize risk
    More tutorialsOther real-world examples and use cases
Community questions

Ask a question

Was this page useful?

HelpfulCould be better

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Needs an MCP server

Security

No issues found by our static scan· No issues found

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Created by
PostHog
Publisher
PostHog (Official)
Source
PostHog/skills · skills/posthog/feature-flags/skills/flutter · commit a5d30e7
Licence
MIT License (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced
Also distributed in
PostHog/skills

AutoGineer is not affiliated with or endorsed by PostHog.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download feature-flags-flutter.zip