Install the Flutter SDK
The Optimizely Feature Experimentation Flutter SDK is open source, and the full source code is available on GitHub.
Platform requirements
Confirm that your app meets these requirements before you install the SDK. Version 4.0.0 raises the Flutter and iOS minimums.
- Flutter – 3.44 or later for version 4.0.0 and later. Version 3.x requires Flutter 2.5 or later.
- iOS – iOS 15.0 or later for version 4.0.0 and later. The SDK integrates with iOS only through Swift Package Manager (SPM), and CocoaPods is not supported. Version 3.x supports iOS 10.0 or later through SPM or CocoaPods.
- Android – Minimum SDK version 21.
Migrate the iOS integration from CocoaPods
Version 4.0.0 supports only SPM on iOS, so move your app off CocoaPods before you upgrade. Flutter migrates the Xcode project when you build.
- Upgrade to Flutter 3.44 or later. Flutter 3.44 turns on SPM by default.
- If your Flutter configuration turns off SPM, run flutter config --enable-swift-package-manager.
- If your app's pubspec.yaml sets enable-swift-package-manager: false, remove that setting.
- Set the iOS deployment target of the Xcode Runner target to 15.0 or later. If your app still has a Podfile, set platform :ios to 15.0 or later.
- Run flutter pub get.
- Run flutter build ios. Flutter migrates your Xcode project to SPM.
- (Optional) If your app uses no other CocoaPods plugins, run pod deintegrate and delete the Podfile.
Add the SDK to your app
Add the SDK as a dependency so your Flutter app can make flag decisions and send events to Feature Experimentation. Include this line in the dependencies block of your app's pubspec.yaml file:
optimizely_flutter_sdk: ^4.0.0If your app must support iOS versions earlier than 15.0, use ^3.8.0 instead. Version 3.8.0 is the last 3.x release.
In a terminal, run the following command to download the package:
flutter pub getInstall from CLI source
Add the dependency and download the package in one step with the Flutter CLI:
flutter pub add optimizely_flutter_sdk:^4.0.0