This repository houses the Flutter SDK for use with Optimizely Feature Experimentation and Optimizely Full Stack (legacy).
Optimizely Feature Experimentation is an A/B testing and feature management tool for product development teams that enables you to experiment at every step. Using Optimizely Feature Experimentation allows for every feature on your roadmap to be an opportunity to discover hidden insights. Learn more at Optimizely.com, or see the developer documentation.
Optimizely Rollouts is free feature flags for development teams. You can easily roll out and roll back features in any application without code deploys, mitigating risk for every feature on your roadmap.
Refer to the Flutter SDK's developer documentation for detailed instructions on getting started with using the SDK.
See the pubspec.yaml file for Flutter version requirements.
On the Android platform, the SDK requires a minimum SDK version of 21 or higher and compile SDK version of 35.
On the iOS platform, the SDK requires a minimum version of 15.0 and Flutter 3.44 or later. The SDK is integrated through Swift Package Manager (SPM) only; CocoaPods is no longer supported.
- Use Flutter 3.44 or later (SPM is enabled by default; otherwise run
flutter config --enable-swift-package-manager). If your app'spubspec.yamlturns SPM off (flutter: config: enable-swift-package-manager: false), remove that setting. - Set your app's iOS deployment target to 15.0 or higher (Xcode Runner target, and
platform :iosin your Podfile if you still have one). - Run
flutter pub getandflutter build ios. Flutter migrates your Xcode project to SPM automatically. - If no other CocoaPods plugins remain, you may run
pod deintegrateand delete your Podfile.
Other Flutter platforms are not currently supported by this SDK.
To add the flutter-sdk to your project dependencies, include the following in your app's pubspec.yaml:
optimizely_flutter_sdk: ^3.8.0
Then run
flutter pub getImport the package in your application code:
import 'package:optimizely_flutter_sdk/optimizely_flutter_sdk.dart';Instantiate the SDK, adding your SDK Key and initializing the client:
var flutterSDK = OptimizelyFlutterSdk("your_sdk_key");
var response = await flutterSDK.initializeClient(); import 'package:optimizely_flutter_sdk/optimizely_flutter_sdk.dart';
// Also supports eventOptions, datafilePeriodicDownloadInterval, datafileHostOptions and defaultDecideOptions
var flutterSDK = OptimizelyFlutterSdk("your_sdk_key");
var response = await flutterSDK.initializeClient();
// User attributes are optional and used for targeting and results segmentation
var attributes = {
"state": "California",
"likes_donuts": true
};
var user = await flutterSDK.createUserContext("user_id", attributes);
var decideReponse = await user!.decide("binary_feature");To run unit tests using terminal, simply use the following command:
flutter test test/optimizely_flutter_sdk_test.dartPlease see CONTRIBUTING.
-
Flutter - https://github.com/optimizely/optimizely-flutter-sdk
-
JavaScript - https://github.com/optimizely/javascript-sdk