variation method

  1. @override
Future<Variation> variation(
  1. int experimentKey, {
  2. HackleUser? user,
})
override

Implementation

@override
Future<Variation> variation(
  int experimentKey, {
  HackleUser? user,
}) async {
  try {
    final Map<String, Object?> arguments = {
      Argument.experimentKey.value: experimentKey,
      Argument.user.value: user?.toMap(),
    };

    final String result = await methodChannel.invokeMethod(
      Method.variation.value,
      arguments,
    );

    return EnumUtil.parseToEnum<Variation>(Variation.values, result);
  } catch (e) {
    log("Failed to variation", level: 3, error: e);
    return Variation.A;
  }
}