getFlag method

Future<GetFlag?> getFlag({
  1. required String flagName,
  2. required VWOContext vwoContext,
})

Gets the value of a feature flag.

flagName The name of the feature flag. vwoContext 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 flagName,
  required VWOContext vwoContext,
}) async {
  try {
    return _fmePlugin?.getFlag(flagName: flagName, vwoContext: vwoContext);
  } 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;
  }
}