{"id":13550550,"url":"https://github.com/alippo-com/GrowthBook-SDK-Flutter","last_synced_at":"2025-04-03T00:34:12.351Z","repository":{"id":37080125,"uuid":"473560392","full_name":"alippo-com/GrowthBook-SDK-Flutter","owner":"alippo-com","description":"An open-source feature flagging and experimentation platform that makes it simple to alter features and execute A/B testing.","archived":false,"fork":false,"pushed_at":"2024-04-30T17:02:03.000Z","size":382,"stargazers_count":12,"open_issues_count":5,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-03T20:35:52.624Z","etag":null,"topics":["abtesting","dart","flutter","growthbook"],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alippo-com.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-24T10:37:24.000Z","updated_at":"2024-04-30T17:02:08.000Z","dependencies_parsed_at":"2024-01-16T18:57:59.544Z","dependency_job_id":"cb272233-32ab-46a2-9cd2-6a428c1d6ed0","html_url":"https://github.com/alippo-com/GrowthBook-SDK-Flutter","commit_stats":{"total_commits":59,"total_committers":4,"mean_commits":14.75,"dds":"0.10169491525423724","last_synced_commit":"48a19e3d14b137d9100c04f6d084c4467aa720bc"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alippo-com%2FGrowthBook-SDK-Flutter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alippo-com%2FGrowthBook-SDK-Flutter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alippo-com%2FGrowthBook-SDK-Flutter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alippo-com%2FGrowthBook-SDK-Flutter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alippo-com","download_url":"https://codeload.github.com/alippo-com/GrowthBook-SDK-Flutter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246916734,"owners_count":20854511,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["abtesting","dart","flutter","growthbook"],"created_at":"2024-08-01T12:01:34.657Z","updated_at":"2025-04-03T00:34:10.683Z","avatar_url":"https://github.com/alippo-com.png","language":"Dart","funding_links":[],"categories":["Dart"],"sub_categories":[],"readme":"# GrowthBook SDK for flutter.\n\n![](https://docs.growthbook.io/images/hero2.png)\n\n\n\n## Overview\n\nGrowthBook is an open source feature flagging and experimentation platform that makes it easy to adjust what features are shown users, and run A/B tests, without deploying new code. There are two parts to GrowthBook, the GrowthBook Application, and the SDKs which implement this functionality to your code base. This Flutter SDK allows you to use GrowthBook with your Flutter based mobile application.\n\n![](https://camo.githubusercontent.com/b1d9ad56ab51c4ad1417e9a5ad2a8fe63bcc4755e584ec7defef83755c23f923/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d616e64726f69642d3645444238442e7376673f7374796c653d666c6174) ![](https://camo.githubusercontent.com/1fec6f0d044c5e1d73656bfceed9a78fd4121b17e82a2705d2a47f6fd1f0e3e5/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d696f732d4344434443442e7376673f7374796c653d666c6174)\n\n\n\n\n- **Lightweight and fast**\n- **Supports**\n  - **Android**\n  - **iOS**\n  - **Mac**\n  - **Windows**\n- **Use your existing event tracking (GA, Segment, Mixpanel, custom)**\n- **Adjust variation weights and targeting without deploying new code**\n\n\n\n## Installation\n\n1. Add GrowthBook SDK as dependency in your pubspec.yaml file.\n```yaml\ngrowthbook_sdk_flutter: ^latest-version\n```\n\n## Integration\n\nIntegration is super easy:\n\n1. Create a GrowthBook API key from the GrowthBook App.\n2. Initialize the SDK at the start of your app using the API key, as below.\n\nNow you can start/stop tests, adjust coverage and variation weights, and apply a winning variation to 100% of traffic, all within the Growth Book App without deploying code changes to your site.\n\n```dart\nfinal GrowthBookSDK sdkInstance = await GBSDKBuilderApp(\n  apiKey: \"\u003cAPI_KEY\u003e\",\n  attributes: {\n    /// Specify attributes.\n  },\n  growthBookTrackingCallBack: (gbExperiment, gbExperimentResult) {},\n  hostURL: '\u003cGrowthBook_URL\u003e',\n  apiKey: '\u003cYOUR API KEY\u003e'\n).initialize();\n\n```\n\nThere are additional properties which can be setup at the time of initialization\n\n```dart\n    final GrowthBookSDK newSdkInstance =await GBSDKBuilderApp(\n    apiKey: \"\u003cAPI_KEY\u003e\",\n    attributes: {\n     /// Specify user attributes.\n    },\n    client: NetworkClient(), // Provide network dispatcher.\n    growthBookTrackingCallBack: (gbExperiment, gbExperimentResult) {},\n    hostURL: '\u003cGrowthBook_URL\u003e',\n    forcedVariations: {} // Optional provide force variation.\n    qaMode: true, // Set qamode\n).initialize();\n\n```\n\n\n\n## Usage\n\n- Initialization returns SDK instance - GrowthBookSDK\n  ###### Use sdkInstance to consume below features -\n\n- The feature method takes a single string argument, which is the unique identifier for the feature and returns a FeatureResult object.\n\n  ```dart\n    GBFeatureResult feature(String id) \n  ```\n\n- The run method takes an Experiment object and returns an ExperimentResult\n\n```dart\n    GBExperimentResult run(GBExperiment experiment)   \n```\n\n- Get Context\n\n```dart\n    GBContext getGBContext()\n```\n\n- Get Features\n\n```dart\n    GBFeatures getFeatures()  \n```\n\n\n\n## Models\n\n```dart\n/// Defines the GrowthBook context.\nclass GBContext {\n  GBContext({\n    this.apiKey,\n    this.hostURL,\n    this.enabled,\n    this.attributes,\n    this.forcedVariation,\n    this.qaMode,\n    this.trackingCallBack,\n  });\n\n  /// Registered API key for GrowthBook SDK.\n  String? apiKey;\n\n  /// Host URL for GrowthBook\n  String? hostURL;\n\n  /// Switch to globally disable all experiments. Default true.\n  bool? enabled;\n\n  /// Map of user attributes that are used to assign variations\n  Map\u003cString, dynamic\u003e? attributes;\n\n  /// Force specific experiments to always assign a specific variation (used for QA).\n  Map\u003cString, dynamic\u003e? forcedVariation;\n\n  /// If true, random assignment is disabled and only explicitly forced variations are used.\n  bool? qaMode;\n\n  /// A function that takes experiment and result as arguments.\n  TrackingCallBack? trackingCallBack;\n\n  /// Keys are unique identifiers for the features and the values are Feature objects.\n  /// Feature definitions - To be pulled from API / Cache\n  GBFeatures features = \u003cString, GBFeature\u003e{};\n}\n```\n\n\n\n```dart\n/// A Feature object consists of possible values plus rules for how to assign values to users.\nclass GBFeature {\n  GBFeature({\n    this.rules,\n    this.defaultValue,\n  });\n\n  /// The default value (should use null if not specified)\n  ///2 Array of Rule objects that determine when and how the defaultValue gets overridden\n  List\u003cGBFeatureRule\u003e? rules;\n\n  ///  The default value (should use null if not specified)\n  dynamic defaultValue;\n}\n\n\n/// Rule object consists of various definitions to apply to calculate feature value\n\nclass GBFeatureRule {\n  GBFeatureRule({\n    this.condition,\n    this.coverage,\n    this.force,\n    this.variations,\n    this.key,\n    this.weights,\n    this.nameSpace,\n    this.hashAttribute,\n  });\n\n  /// Optional targeting condition\n  GBCondition? condition;\n\n  /// What percent of users should be included in the experiment (between 0 and 1, inclusive)\n  double? coverage;\n\n  /// Immediately force a specific value (ignore every other option besides condition and coverage)\n  dynamic force;\n\n  /// Run an experiment (A/B test) and randomly choose between these variations\n  List\u003cdynamic\u003e? variations;\n\n  /// The globally unique tracking key for the experiment (default to the feature key)\n  String? key;\n\n  /// How to weight traffic between variations. Must add to 1.\n  List\u003cdouble\u003e? weights;\n\n  /// A tuple that contains the namespace identifier, plus a range of coverage for the experiment.\n  List? nameSpace;\n\n  /// What user attribute should be used to assign variations (defaults to id)\n  String? hashAttribute;\n}\n\n\n/// Enum For defining feature value source.\nenum GBFeatureSource {\n  /// Queried Feature doesn't exist in GrowthBook.\n  unknownFeature,\n\n  /// Default Value for the Feature is being processed.\n  defaultValue,\n\n  /// Forced Value for the Feature is being processed.\n  force,\n\n  /// Experiment Value for the Feature is being processed.\n  experiment\n}\n\n/// Result for Feature\nclass GBFeatureResult {\n  GBFeatureResult({\n    this.value,\n    this.on,\n    this.off,\n    this.source,\n    this.experiment,\n    this.experimentResult,\n  });\n\n  /// The assigned value of the feature\n  dynamic value;\n\n  /// The assigned value cast to a boolean\n  bool? on = false;\n\n  /// The assigned value cast to a boolean and then negated\n  bool? off = true;\n\n  /// One of \"unknownFeature\", \"defaultValue\", \"force\", or \"experiment\"\n\n  GBFeatureSource? source;\n\n  /// When source is \"experiment\", this will be the Experiment object used\n  GBExperiment? experiment;\n\n  ///When source is \"experiment\", this will be an ExperimentResult object\n  GBExperimentResult? experimentResult;\n}\n```\n\n\n\n```dart\n/// Defines a single experiment\n\nclass GBExperiment {\n  GBExperiment({\n    this.key,\n    this.variations,\n    this.namespace,\n    this.condition,\n    this.hashAttribute,\n    this.weights,\n    this.active = true,\n    this.coverage,\n    this.force,\n  });\n\n  /// The globally unique tracking key for the experiment\n  String? key;\n\n  /// The different variations to choose between\n  List? variations = [];\n\n  /// A tuple that contains the namespace identifier, plus a range of coverage for the experiment\n  List? namespace;\n\n  /// All users included in the experiment will be forced into the specific variation index\n  String? hashAttribute;\n\n  /// How to weight traffic between variations. Must add to 1.\n  List? weights;\n\n  /// If set to false, always return the control (first variation)\n  bool active;\n\n  /// What percent of users should be included in the experiment (between 0 and 1, inclusive)\n  double? coverage;\n\n  /// Optional targeting condition\n  GBCondition? condition;\n\n  /// All users included in the experiment will be forced into the specific variation index\n  int? force;\n\n  ///Check if experiment is not active.\n  bool get deactivated =\u003e !active;\n}\n\n/// The result of running an Experiment given a specific Context\nclass GBExperimentResult {\n  GBExperimentResult({\n    this.inExperiment,\n    this.variationID,\n    this.value,\n    this.hasAttributes,\n    this.hashValue,\n  });\n\n  /// Whether or not the user is part of the experiment\n  bool? inExperiment;\n\n  /// The array index of the assigned variation\n  int? variationID;\n\n  /// The array value of the assigned variation\n  dynamic value;\n\n  /// The user attribute used to assign a variation\n  String? hasAttributes;\n\n  /// The value of that attribute\n  String? hashValue;\n}\n\n```\n\n## License\n\nThis project uses the MIT license. The core GrowthBook app will always remain open and free, although we may add some commercial enterprise add-ons in the future.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falippo-com%2FGrowthBook-SDK-Flutter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falippo-com%2FGrowthBook-SDK-Flutter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falippo-com%2FGrowthBook-SDK-Flutter/lists"}