Optimizely will be sunsetting Full Stack Experimentation on July 29, 2024. See the recommended Feature Experimentation migration timeline and documentation.

Dev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket

Get Forced Variation

This topic describes the Get Forced Variation method, which returns the forced variation set by Set Forced Variation, or null if no variation was forced for the Flutter SDK.

A user can be forced into a variation for a given experiment for the lifetime of the Optimizely client. This method gets the variation that the user has been forced into. The forced variation value is runtime only and does not persist across application launches.


1.0.1 and higher


Forced bucketing variations take precedence over whitelisted variations, variations saved in a User Profile Service (if one exists), and the normal bucketed variation. Variations are overwritten when Set Forced Variation is invoked.



A forced variation only persists for the lifetime of an Optimizely client.


This table lists the required and optional parameters for the Flutter SDK.

stringThe key of the experiment to retrieve the forced variation.
stringThe ID of the user in the forced variation.


The variation response containing request status and variation key as a string or null


var variationResponse = await flutterSDK?.getForcedVariation("my_experiment_key", "user_123");
var variationKey = variationResponse?.variationKey;

Source files

The language/platform source files containing the implementation for Flutter Android is at Optimizely.java and for Flutter IOS is at OptimizelyClient.swift.