GithubHelp home page GithubHelp logo

Comments (2)

Milad-Akarie avatar Milad-Akarie commented on July 1, 2024

@guplem do you have a nested routes setup? show full graph

from auto_route_library.

guplem avatar guplem commented on July 1, 2024

This is my full router class:

@AutoRouterConfig(replaceInRouteName: 'Page,Route') //"HomePage" will be generated as "HomeRoute" because of the replaceInRouteName property
class AppRouter extends $AppRouter implements AutoRouteGuard {
  BuildContext? get context => super.navigatorKey.currentContext;

  static final AppRouter _instance = AppRouter.internal(GlobalKey<NavigatorState>());

  AppRouter.internal(GlobalKey<NavigatorState> navigatorKey) : super(navigatorKey: navigatorKey);

  factory AppRouter() => _instance;

  @override
  List<AutoRoute> get routes => [
        AutoRoute(page: HomeRoute.page, path: "/", guards: [AuthGuard()]),
        AutoRoute(page: ForceUpdateRoute.page, path: "/update", guards: [AuthGuard()]),
        AutoRoute(page: AuthRoute.page, path: "/auth"),
        AutoRoute(page: ProfileRoute.page, path: "/profile", guards: [AuthGuard()]),
        AutoRoute(page: PeopleRoute.page, path: "/people", guards: [AuthGuard()]),
        AutoRoute(page: LiveRoute.page, path: "/lives", guards: [AuthGuard()]),
        AutoRoute(page: PlanRoute.page, path: "/plan/:planId", guards: [AuthGuard()]),
        AutoRoute(page: ChatsV2Route.page, path: "/chats", guards: [AuthGuard()]),
        AutoRoute(page: ChatV2Route.page, path: "/chat/:chatId", guards: [AuthGuard()]),
        AutoRoute(page: SettingsRoute.page, path: "/settings", guards: [AuthGuard()]),
        AutoRoute(page: DevToolsRoute.page, path: "/dev-tools", guards: [AuthGuard()]),
        AutoRoute(page: DemosRoute.page, path: "/dev-demos", guards: [AuthGuard()]),
        AutoRoute(page: WebViewRoute.page, path: "/web-view/:url", guards: [AuthGuard()]),
        AutoRoute(page: MediaSelectionRoute.page, path: "/media-selection", guards: [AuthGuard()]),
        AutoRoute(page: MediaGalleryRoute.page, path: "/media-gallery", guards: [AuthGuard()]),
        AutoRoute(page: MediaViewerRoute.page, path: "/media-viewer", guards: [AuthGuard()]),
        AutoRoute(page: MessageInfoRoute.page, path: "/message-info", guards: [AuthGuard()]),
        AutoRoute(page: CoordinatesSelectionRoute.page, path: "/coordinates-selection", guards: [AuthGuard()]),
        AutoRoute(page: CoordinatesViewerRoute.page, path: "/coordinates-viewer", guards: [AuthGuard()]),
        RedirectRoute(redirectTo: '/', path: "*"), // https://github.com/Milad-Akarie/auto_route_library#wildcards
      ];

  @override
  void onNavigation(NavigationResolver resolver, StackRouter router) {
    AnalyticsService().logEvent(eventType: EventType.navigation, identifier: resolver.route.name, currentRoute: router.current.name, data: resolver.route.queryParams.rawMap);
    if (resolver.route.name != ForceUpdateRoute.name) {
      if (UpdateService().isVersionValid) {
        resolver.next();
      } else {
        resolver.redirect(const ForceUpdateRoute(), replace: true);
      }
    } else {
      resolver.next();
    }
  }

  static Uri planDeepLink(String planId) {
    return Uri(
      scheme: GlobalDataService.webUrl.scheme,
      host: GlobalDataService.webUrl.host,
      path: "/plan/$planId",
    );
  }
}

from auto_route_library.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.