1
class SearchModule extends ModuleWidget {
  @override
  List<Bind> get binds => [
        Bind((i) => SearchController()),
      ];

  @override
  List<Router> get routers => [
        Router(Modular.initialRoute, child: (_, args) => SearchPage()),
        Router("teacher", child: (_, args) => TeacherListPage()),
      ];

  @override
  Widget get view => SearchPage();

  static Inject get to => Inject<SearchModule>.of();
}

I can't access the "teacher" route for this module. That is, I cannot navigate to this route using the method Modular.to.pushNamed('/teacher', arguments: TeacherListPage())

I get the following error .: Could not find a generator for route RouteSettings("/teacher", TeacherListPage) in the _WidgetsAppState.

Can anyone give me a light?? kkk

Follow the flow of the modules.:

I/flutter (13793): -- AppModule INITIALIZED
I/flutter (13793): -- HomeModule INITIALIZED
I/flutter (13793): -- ReviewsModule INITIALIZED
I/flutter (13793): -- HomeModule DISPOSED
I/flutter (13793): -- SearchModule INITIALIZED

Follows the structure of the modules .:

<------------------------------------------------------------------------>

class AppModule extends MainModule {
  @override
  List<Bind> get binds => [
        Bind((i) => TeacherListController()),
        Bind((i) => ReviewsContentController()),
        Bind((i) => SigninController()),
        Bind((i) => SignupController()),
        Bind((i) => AppController()),
      ];

  @override
  List<Router> get routers => [
        Router(Modular.initialRoute, module: HomeModule()),
        Router('/reviews', module: ReviewsModule()),
      ];

  @override
  Widget get bootstrap => AppWidget();

  static Inject get to => Inject<AppModule>.of();
}

<------------------------------------------------------------------------>

class HomeModule extends ChildModule {
  @override
  List<Bind> get binds => [
        Bind((i) => HomeController()),
      ];

  @override
  List<Router> get routers => [
        Router(Modular.initialRoute, child: (_, args) => HomePage()),
        Router("signUp", child: (_, args) => SignupPage()),
        Router("signIn", child: (_, args) => SigninPage()),
      ];

  static Inject get to => Inject<HomeModule>.of();
}

<------------------------------------------------------------------------>

class ReviewsModule extends ChildModule {
  @override
  List<Bind> get binds => [
        Bind((i) => ReviewsController()),
      ];

  @override
  List<Router> get routers => [
        Router(Modular.initialRoute, child: (_, args) => ReviewsPage()),
      ];

  static Inject get to => Inject<ReviewsModule>.of();
}

<------------------------------------------------------------------------>

class SearchModule extends ModuleWidget {
  @override
  List<Bind> get binds => [
        Bind((i) => SearchController()),
      ];

  @override
  List<Router> get routers => [
        Router(Modular.initialRoute, child: (_, args) => SearchPage()),
        Router("teacher", child: (_, args) => TeacherListPage()),
      ];

  @override
  Widget get view => SearchPage();

  static Inject get to => Inject<SearchModule>.of();
}

<------------------------------------------------------------------------>

1 Answers1

1

The solution was that I was wrongly calling the route.

When I tried to call the route that was inside the SearchModule module, I was not making the correct path to it, that is, I was calling it as follows:

Modular.to.pushNamed('/teacher')

However, when it is called that way, the first thing Modular does is check if this route exists in the AppModule Module, and as shown above, there is only the route

Router('/reviews', module: ReviewsModule()),

Therefore, the correct way to navigate would be to go "inside" the modules until you reach the SearchModule module which has the route for teacher. Remembering that I had to add within the ReviewsModule module the route for SearchModule that finally has the route for teacher.

Soon I had to add,

Router('/search', module: SearchModule()),

And finally, the correct call would be,

Modular.to.pushNamed('/reviews/search/teacher')