flag method

Future<FeatureFlag> flag(
  1. String name, {
  2. bool useResultCache = true,
})

Gets and evaluates a feature flag with the given name.

useResultCache determines if the result cache should be used when evaluating the flag. Defaults to true.

Throws a PlatformException if the flag fails to resolve, e.g. if the flags have not yet been downloaded or Airship is not ready.

Implementation

Future<FeatureFlag> flag(String name, {bool useResultCache = true}) async {
  var featureFlag = await _module.channel.invokeMethod(
    "featureFlagManager#flag",
    {
      "flagName": name,
      "useResultCache": useResultCache,
    },
  );

  if (featureFlag == null) {
    throw PlatformException(
      code: "AIRSHIP_ERROR",
      message: "Failed to fetch feature flag: $name",
      details: "Method: featureFlagManager#flag",
    );
  }

  return FeatureFlag._fromJson(featureFlag);
}