Remote Config
Remote Config in the Flutter SDK.
import 'package:nexus_flutter/nexus.dart';NexusRemoteConfig
classFirebase-style Remote Config. Fetches the active template for this app instance, resolves conditional values server-side, and exposes typed getters with in-app defaults as the fallback.
nexus.remoteConfig.setDefaults({'welcome': 'Hi', 'max_items': 10});
await nexus.remoteConfig.fetch();
final msg = nexus.remoteConfig.getString('welcome');onChange
propertyStream<void> get onChangeEmits after every fetch that changes the active values.
View sourceversion
propertyint get versionThe active template version last fetched (0 until first fetch).
View sourcelastFetchTime
propertyDateTime? get lastFetchTimeattributes
propertyMap<String, Object?> get attributesThe custom targeting attributes currently sent with fetches.
View sourcesetDefaults()
methodvoid setDefaults(Map<String, Object?> defaults)Set in-app fallback values (used until the server provides a value).
Merges with any existing defaults. Mirrors Firebase setDefaults.
Parameters
Prop
Type
setAttributes()
methodvoid setAttributes(Map<String, Object?> attributes)Custom targeting attributes sent with every fetch (e.g. governorate,
plan, segment). These feed "Custom attribute" conditions on the server.
Merges with existing attributes; call clearAttributes to reset. Mirrors
Firebase custom signals. Values must be string/number/bool.
Parameters
Prop
Type
setAttribute()
methodvoid setAttribute(String key, Object? value)Set (or replace) a single custom targeting attribute. Pass null to remove.
Parameters
Prop
Type
clearAttributes()
methodvoid clearAttributes()fetch()
methodFuture<bool> fetch({Map<String, Object?>? attributes})Fetch the active template and activate it. Returns true when the values
changed since the last fetch. attributes are merged (for this fetch only)
over the persistent ones set via setAttributes. Best-effort — never throws.
Parameters
Prop
Type
Returns Future<bool>
getValue()
methodObject? getValue(String key)The raw value for key (server value, else in-app default, else null).
Parameters
Prop
Type
Returns Object?
getString()
methodString getString(String key, [String fallback = ''])Parameters
Prop
Type
Returns String
getBool()
methodbool getBool(String key, [bool fallback = false])Parameters
Prop
Type
Returns bool
getInt()
methodint getInt(String key, [int fallback = 0])Parameters
Prop
Type
Returns int
getDouble()
methoddouble getDouble(String key, [double fallback = 0])Parameters
Prop
Type
Returns double
getJson()
methodObject? getJson(String key, [Object? fallback])A JSON value (Map/List) for key, or fallback when absent.
Parameters
Prop
Type
Returns Object?
sourceOf()
methodString? sourceOf(String key)The condition that supplied key's value (null when the default applied).
Parameters
Prop
Type
Returns String?
getAll()
methodMap<String, Object?> getAll()Every currently-active key → value (server values overlaid on defaults).
Returns Map<String, Object?>
subscribeRealtime()
methodFuture<void> subscribeRealtime(NexusRealtime realtime)Subscribe to server-pushed config updates: on a new publish, re-fetch. Requires an active realtime connection. Safe to call more than once.
Parameters
Prop
Type
unsubscribeRealtime()
methodFuture<void> unsubscribeRealtime()dispose()
methodvoid dispose()