InAppMessagesNavigatorObserver class

A NavigatorObserver that automatically notifies PPGInAppMessages about route changes.

Add this observer to your MaterialApp or Navigator to automatically track navigation and display eligible in-app messages.

Example with MaterialApp:

MaterialApp(
  navigatorObservers: [
    InAppMessagesNavigatorObserver(),
  ],
  // ... rest of your app
)

Example with Navigator:

Navigator(
  observers: [
    InAppMessagesNavigatorObserver(),
  ],
  // ... rest of your navigator
)

By default, the observer uses the route's settings name as the route identifier. You can customize this by providing a routeNameExtractor.

Example with custom route name extraction:

InAppMessagesNavigatorObserver(
  routeNameExtractor: (route) {
    // Custom logic to extract route name
    if (route?.settings.name?.contains('product') == true) {
      return 'product_detail';
    }
    return route?.settings.name;
  },
)
Inheritance

Constructors

InAppMessagesNavigatorObserver({String? routeNameExtractor(Route? route)?})
Creates an observer that notifies PPGInAppMessages about route changes.

Properties

hashCode int
The hash code for this object.
no setterinherited
The navigator that the observer is observing, if any.
no setterinherited
routeNameExtractor String? Function(Route? route)?
Optional function to extract route name from a Route. If not provided, uses route.settings.name.
final
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.
override
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