kind method

LDAttributesBuilder kind(
  1. String kind, [
  2. String? key
])

Adds another kind to the context. kind and optional key must be non-empty. Calling this method again with the same kind returns the same LDAttributesBuilder as before.

If key is omitted and LDAttributesBuilder.anonymous is set to true, the SDK will automatically generate a stable key for this context during LDClient.start or LDClient.identify. The generated key will be persisted on the device and reused for future application runs.

If key is omitted and anonymous is not set to true, the context will be invalid.

Implementation

LDAttributesBuilder kind(String kind, [String? key]) {
  LDAttributesBuilder builder = _buildersByKind.putIfAbsent(
      kind, () => LDAttributesBuilder._internal(this, kind));

  if (key != null) {
    // key may be different on this subsequent call, so need to update it.
    builder._key = key;
  }

  return builder;
}