getFlag method

Future<GetFlag?> getFlag({
  1. required String featureKey,
  2. required VWOUserContext context,
})

Gets the value of a feature flag.

featureKey The name of the feature flag. context The user context for evaluating the flag.

Returns a Future that resolves to a GetFlag object containing the flag value and other metadata.

Implementation

Future<GetFlag?> getFlag(
    {required String featureKey, required VWOUserContext context}) async {
  try {
    return _fmePlugin?.getFlag(featureKey: featureKey, userContext: context);
  } catch (e) {
    String details;
    if (e is PlatformException) {
      details = e.message ?? '';
    } else {
      details = e.toString();
    }
    logMessage('VWO: Failed to retrieve feature flag $details');
    return null;
  }
}