analytics_flutter icon indicating copy to clipboard operation
analytics_flutter copied to clipboard

Issue in ScreenObserver

Open mschlegelaware opened this issue 9 months ago • 1 comments

In the didPop function inside the ScreenObserver is an issue.

the code:

  @override
  void didPop(Route<dynamic> route, Route<dynamic>? previousRoute) {
    final name = route.settings.name;
    if (name != null) {
      screenStreamController.add(name);
    }
  }

From the documentation from didPop:

The Navigator popped route.
The route immediately below that one, and thus the newly active route, is previousRoute.
Copied from NavigatorObserver.

Therefore the code should be:

  @override
  void didPop(Route<dynamic> route, Route<dynamic>? previousRoute) {
    final name = previousRoute.settings.name;
    if (name != null) {
      screenStreamController.add(name);
    }
  }

previousRoute is the new route, and therefore that is the name which should be tracked, not route.

mschlegelaware avatar May 21 '24 09:05 mschlegelaware