setFeatureState method

Future setFeatureState(
  1. String sdkUrl,
  2. String featureKey,
  3. FeatureStateUpdate featureStateUpdate, {
  4. Options? options,
})

Requests all features for this sdkurl and disconnects

Updates the feature state if allowed.

Implementation

Future<dynamic> setFeatureState(
    String sdkUrl, String featureKey, FeatureStateUpdate featureStateUpdate,
    {Options? options}) async {
  final response = await apiDelegate.setFeatureState(
    sdkUrl,
    featureKey,
    featureStateUpdate,
    options: options,
  );

  if (![200, 201, 202, 400, 403, 404, 412].contains(response.statusCode)) {
    throw ApiException(500,
        'Invalid response code ${response.statusCode} returned from API');
  }

  final __body = response.body;
  if (response.statusCode >= 400) {
    throw ApiException(response.statusCode,
        __body == null ? null : await decodeBodyBytes(__body));
  }

  if (__body == null) {
    throw ApiException(500, 'Received an empty body (not in a 204)');
  }

  return await apiDelegate.setFeatureState_decode(__body);
}