objectVariationDetails method

Future<BKTEvaluationDetails<BKTValue>> objectVariationDetails(
  1. String featureId, {
  2. required BKTValue defaultValue,
})

Implementation

Future<BKTEvaluationDetails<BKTValue>> objectVariationDetails(
  String featureId, {
  required BKTValue defaultValue,
}) async {
  final userId = await _getCurrentUserIdOrEmpty();
  return valueGuard<BKTEvaluationDetails<BKTValue>>(
    await _invokeMethod(CallMethods.objectVariationDetails.name, argument: {
      CallMethodParams.featureId: featureId,
      // Important: need encode the default value as json String
      CallMethodParams.defaultValue: jsonEncode(defaultValue.toJson()),
    }),
    customMapping: (response) {
      final rs = BKTEvaluationDetails.fromJson<BKTValue>(
        response,
        converter: const BKTValueTypeConverter(),
      );
      return rs;
    },
  ).onError((error, stackTrace) {
    debugPrint("get objectVariationDetails fail: ${error?.toString()}");
    return BKTEvaluationDetails.createDefaultValue(
        featureId, userId, defaultValue);
  });
}