getVariation abstract method

Future<Variation> getVariation(
  1. String featureKey, {
  2. bool track = true,
})

Retrieves the Variation assigned to a given visitor for a specific feature flag.

This method takes a featureKey as a mandatory argument. The track argument is optional and defaults to true. It returns the assigned Variation for the visitor. If the visitor is not associated with any feature flag rules, the method returns the default Variation for the given feature flag.

Ensure proper error handling is implemented in your code to manage potential exceptions.

  • Parameters:
    • featureKey: The unique identifier of the feature flag.
    • track: A flag indicating whether tracking is enabled (true) or disabled (false). If not provided, it defaults to true.
  • Returns: The Variation assigned to the visitor for the specified feature flag.
  • Throws:
    • SDKNotReady if the SDK has not finished its initialization.
    • FeatureNotFound if the requested feature key is not found in the SDK's internal configuration. This may occur if the feature flag has not been added on the Kameleoon platform, even though the code is deployed on the application.
    • FeatureEnvironmentDisabled if the requested feature flag is disabled in the current environment.

Implementation

Future<Variation> getVariation(String featureKey, {bool track = true});