Nexus class
The Nexus umbrella SDK — one entry point for every service. Initialise once at startup; then use any service, all correlated to the same journey session:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Nexus.init(const NexusConfig(apiKey: 'nxs_...'));
runApp(NexusScope(child: MyApp()));
}
// anywhere with a BuildContext:
context.nexus.events.track('order_placed');
context.nexus.realtime.join('orders:42');
Properties
- config → NexusConfig
-
final
- distinctId → String?
-
no setter
- errors ↔ NexusErrors
-
latefinal
- events ↔ NexusEvents
-
latefinal
- flags ↔ NexusFlags
-
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
- inApp ↔ NexusInApp
-
latefinal
- links ↔ NexusLinks
-
latefinal
- liveActivity ↔ NexusLiveActivity
-
latefinal
- logs ↔ NexusLogs
-
latefinal
- pendingUploads → int
-
Number of telemetry requests awaiting delivery (queued/offline).
no setter
- push ↔ NexusPush
-
latefinal
- realtime ↔ NexusRealtime
-
latefinal
- remoteConfig ↔ NexusRemoteConfig
-
latefinal
- replay ↔ NexusReplay
-
latefinal
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sessionKey → String
-
no setter
- sessions ↔ NexusSessions
-
latefinal
- surveys ↔ NexusSurveys
-
latefinal
- voice ↔ NexusVoice
-
latefinal
Methods
-
dispose(
) → void - Tear down the instance (timers, socket, http).
-
flush(
) → Future< void> - Flush all buffered telemetry into the outbox and try to deliver it now (call before the app is backgrounded/killed).
-
identify(
String distinctId, {String? email, String? name, String? phone, Map< String, Object?> ? traits}) → Future<void> -
Identify the current end-user (shorthand for
sessions.identify). -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
observeRouter(
Listenable router, String currentPath()) → void -
Track navigation from a Listenable router (e.g. GoRouter's
routerDelegate) — catches shell/nested routes a root observer misses. See NexusReplay.observeRouter. -
reset(
) → Future< void> - Forget the current user and start a fresh session (e.g. on logout). Also clears the persisted identity so the next launch starts anonymous.
-
toString(
) → String -
A string representation of this object.
inherited
-
trackScreen(
String name) → void -
Record a screen/page change for session replay's Pages tab. Wire
NexusNavigatorObserver into
navigatorObserversto do this automatically.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- instance → Nexus
-
The app-wide instance. Throws if init hasn't run.
no setter
- isInitialized → bool
-
no setter
Static Methods
-
init(
NexusConfig config) → Future< Nexus> - Initialise the SDK once at startup. Re-calling disposes the previous instance and replaces it.