Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'didInitTabRoute' for child AutoTabsRouter called earlier then 'didChangeTabRoute' of parent AutoTabsRouter - bug after updating package #2132

Open
intsitesdotru opened this issue Jan 16, 2025 · 1 comment

Comments

@intsitesdotru
Copy link

Hi, we track routes in AutoRouteObserver for our app analytics, but after updating from 7.8.4 to the latest 9.3.0 version, we noticed that the order of routes in the history has changed slightly. Is this a bug in the new version of the package, or was the behavior in the old version incorrect?

import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'main.dart';

part 'router.gr.dart';

class AppNavigatorObserver extends AutoRouteObserver {
  @override
  void didInitTabRoute(TabPageRoute route, TabPageRoute? previousRoute) {
    print(route.name);
    super.didInitTabRoute(route, previousRoute);
  }

  @override
  void didChangeTabRoute(TabPageRoute route, TabPageRoute previousRoute) {
    print(route.name);
    super.didChangeTabRoute(route, previousRoute);
  }

  @override
  void didPop(Route<dynamic> route, Route<dynamic>? previousRoute) {
    print(route.settings.name);
    super.didPop(route, previousRoute);
  }

  @override
  void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) {
    print(route.settings.name);
    super.didPush(route, previousRoute);
  }
}

@AutoRouterConfig()
class NestedRouter extends RootStackRouter {
  @override
  List<AutoRoute> get routes => [
        AutoRoute(
          initial: true,
          page: HostRoute.page,
          children: [
            AutoRoute(
              page: HostFirstRoute.page,
              children: [
                AutoRoute(
                  initial: true,
                  page: FirstARoute.page,
                ),
                AutoRoute(page: FirstBRoute.page),
              ],
            ),
            AutoRoute(
              initial: true,
              page: SecondRoute.page,
            ),
          ],
        ),
      ];
}

prints for 7.8.4 version
history_7 8 4
prints for 9.3.0 version
history_9 3 0

If the title and description don't provide enough information, I can add a simple example demonstrating that the order of calls for the nested and outer AutoTabsRouter changed. Thank you.

@masreplay
Copy link

any updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants