FeatClient class
A thin client over the feat remote-evaluation endpoints.
feat evaluates flags server side and returns resolved values only, so this
client does no local evaluation: it polls POST /sdk/v1/evaluate and,
optionally, holds a Server-Sent Events stream on GET /sdk/v1/eval/stream
for near-instant updates. Resolved values are cached so the typed getters
(getBool, getString, getNumber, getObject, getDetail) are
synchronous.
Properties
-
changes
→ Stream<
FlagChange> -
A broadcast stream of per-flag value changes. Under the default streaming
policy, subscribing opens the live stream and cancelling the last
subscription closes it.
no setter
- currentContext → EvalContext?
-
The context currently being evaluated, if any.
no setter
- currentVersion → int?
-
The datafile version of the currently-held snapshot, if any.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
allFlags(
) → Map< String, EvaluatedFlag> - An immutable snapshot of every currently-cached flag.
-
close(
) → Future< void> - Tear down all timers, the stream, the change controller, and (if owned) the HTTP client. The client is not reusable afterwards.
-
getBool(
String key, bool defaultValue) → bool -
Resolve a boolean flag synchronously, returning
defaultValuewhen the flag is missing or is not a boolean. -
getDetail(
String key, {Object? defaultValue}) → EvaluatedFlag -
Resolve the full evaluation detail (value, variationId, reason). When the
flag is unknown, returns an EvaluatedFlag carrying
defaultValueand reason EvalReason.error. -
getNumber(
String key, double defaultValue) → double -
Resolve a numeric flag synchronously as a double, returning
defaultValueon a missing or non-numeric value. -
getObject(
String key, Map< String, dynamic> defaultValue) → Map<String, dynamic> -
Resolve an object (JSON map) flag synchronously, returning
defaultValueon a missing or non-object value. -
getString(
String key, String defaultValue) → String -
Resolve a string flag synchronously, returning
defaultValueon a missing or non-string value. -
handleAppLifecycleState(
FeatAppLifecycleState state) → void -
Forward an app lifecycle transition.
resumedresumes live updates; every other state pauses them. Lets a FlutterWidgetsBindingObserverdrive the client without the core package depending on Flutter. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pause(
) → void - Pause live updates (stop polling and drop the stream) without discarding cached values. Intended for when the app is backgrounded.
-
refresh(
) → Future< bool> - Force a one-shot evaluation now. Returns true if the cache changed.
-
resume(
) → void - Resume live updates after pause: refresh immediately, restart polling, and reopen the stream if the policy wants one.
-
setContext(
EvalContext context) → Future< void> - Swap the evaluation context: re-polls immediately, reconnects the stream (so the server evaluates against the new context), and serves any cached snapshot for the new context in the meantime. Emits FlagChange events for every flag whose value differs from the previous context.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
initialize(
FeatClientConfig config) → Future< FeatClient> - Construct and initialize a client. Resolves after the first evaluation lands or FeatClientConfig.initializeTimeout elapses, whichever comes first. On timeout the returned client is still usable; it serves cached or default values until the network responds.