CxNavigatorObserver class

A drop-in NavigatorObserver that reports the active screen to Coralogix on every route change by calling CxFlutterPlugin.setView.

Add it to your app's navigator and route changes are tracked automatically — no need to sprinkle setView calls across every page's initState:

MaterialApp(
  navigatorObservers: [CxNavigatorObserver()],
  // ...
);

setView is what drives the native SDK's product-analytics fields (view_number and isNavigationEvent) onto the emitted RUM events, so this observer is the zero-boilerplate way to get screen-flow analytics.

Which routes are tracked

Only PageRoutes are tracked. Dialogs, bottom sheets, popups and other non-page overlays are not treated as a screen change — dismissing a dialog leaves you on the same page, so it does not re-fire a view.

Naming

The view name is taken from RouteSettings.name. Routes without a name are ignored (no setView is emitted), so either name your routes:

MaterialPageRoute(
  settings: const RouteSettings(name: 'Cart'),
  builder: (_) => const CartPage(),
);

...or pass a custom nameExtractor to derive a name some other way (return null from it to skip a route):

CxNavigatorObserver(
  nameExtractor: (route) => route.settings.name ?? route.runtimeType.toString(),
);
Inheritance

Constructors

CxNavigatorObserver({String? nameExtractor(Route route)?})

Properties

hashCode int
The hash code for this object.
no setterinherited
The navigator that the observer is observing, if any.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

didChangeTop(Route topRoute, Route? previousTopRoute) → void
The top most route has changed.
inherited
didPop(Route route, Route? previousRoute) → void
The Navigator popped route.
override
didPush(Route route, Route? previousRoute) → void
The Navigator pushed route.
override
didRemove(Route route, Route? previousRoute) → void
The Navigator removed route.
inherited
didReplace({Route? newRoute, Route? oldRoute}) → void
The Navigator replaced oldRoute with newRoute.
override
didStartUserGesture(Route route, Route? previousRoute) → void
The Navigator's routes are being moved by a user gesture.
inherited
didStopUserGesture() → void
User gesture is no longer controlling the Navigator.
inherited
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

Static Methods

defaultNameExtractor(Route route) String?
Resolves a view name from RouteSettings.name. Returns null for unnamed routes so they are skipped. Used unless a custom nameExtractor is given.