intVariationDetail static method Null safety

Future<LDEvaluationDetail<int>> intVariationDetail(
  1. String flagKey,
  2. int defaultValue
)

Returns the value of flag flagKey for the current context as an int, along with information about the resultant value.

See LDEvaluationDetail for more information on the returned value. Note that LDConfigBuilder.evaluationReasons must have been set to true to request the additional evaluation information from the backend.

Implementation

static Future<LDEvaluationDetail<int>> intVariationDetail(String flagKey, int defaultValue) async {
  Map<String, dynamic>? result = await _channel.invokeMapMethod('intVariationDetail', {'flagKey': flagKey, 'defaultValue': defaultValue });
  if (result == null) {
    return LDEvaluationDetail(defaultValue, -1, LDEvaluationReason.error());
  }
  int? resultValue = result['value'];
  if (resultValue == null) {
    return LDEvaluationDetail(defaultValue, -1, LDEvaluationReason.error());
  }
  return LDEvaluationDetail(resultValue, result['variationIndex'] ?? -1, LDEvaluationReason._fromCodecValue(result['reason']));
}