LDContextBuilder class final

A builder to facilitate the creation of LDContexts. Note that the return type of kind is a LDAttributesBuilder that is used to define attributes for the specific kind of context you are creating.

LDContextBuilder builder = LDContextBuilder();
builder.kind('user', 'user-key-123abc')
  .name('Sandy Smith')
  .setString('employeeID', 'ID-1234');
builder.kind('company', 'company-key-123abc')
  .name('ExampleCompany');
builder.kind('options', 'options-key-123abc')
  .setValue('advanced', LDValue.buildObject().addBool('poweruser', true).build())
LDContext context = builder.build();

Constructors

LDContextBuilder()
LDContextBuilder.fromContext(LDContext context)
Create a context builder from an existing context. If the context is not valid, then no attributes will be transcribed.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

build() LDContext
Builds the context.
kind(String kind, [String? key]) LDAttributesBuilder
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.
mergeContext(LDContext context) LDContextBuilder
Adds a context to the context builder combining the provided context kinds with the existing kinds in the builder. This function is not normally needed as the kind method can be used for making a multi-context.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited