segmentio / analytics_flutter

The hassle-free way to add Segment analytics to your Flutter app.
MIT License
26 stars 33 forks source link

Issue in ScreenObserver #81

Closed mschlegelaware closed 3 weeks ago

mschlegelaware commented 1 month ago

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.

edsonjab commented 1 month ago

Hi @mschlegelaware thank you for your report, we start looking into this.