modular icon indicating copy to clipboard operation
modular copied to clipboard

ChildRoute fails to render if it has RouterOutlet

Open bandinopla opened this issue 2 years ago • 0 comments

Describe the bug This example never updates the title if you use RouterOutlet and the urls have childrens.


class AppModule extends Module {
  @override
  void binds(i) {}

  @override
  void routes(r) {
    r.child('/test/:dummy',
        child: (context) => Column(
              children: [
                Text("This title never changes = ${r.args.params["dummy"]}"), //<--- NEVER CHANGES
                ElevatedButton(
                  onPressed: () => Modular.to.navigate('/test/cat/info'),
                  child: const Text('Navigate to /test/cat/info'),
                ),
                ElevatedButton(
                  onPressed: () => Modular.to.navigate('/test/dog/info'),
                  child: const Text('Navigate to /test/dog/info'),
                ),
                Expanded(child: RouterOutlet()) //<--- if you comment this line and remove the "/info" form the naviate urls it works.
              ],
            ),
        children: [
          ChildRoute('/info', child: (context) => Text("Info")),
          ChildRoute('/log', child: (context) => Text("log")),
        ]);
  }
}

I would expect the "child" builder from the '/test/:dummy' to be called each time the ":dummy" changes. But it doesn't do that if it has child routes...

this works if you remove the RouterOutlet


    r.child('/test/:dummy',
        child: (context) => Column(
              children: [
                Text(
                    "This title never changes = ${r.args.params["dummy"]}"), //<<--
                ElevatedButton(
                  onPressed: () => Modular.to.navigate('/test/cat'),
                  child: const Text('Navigate to /test/cat/info'),
                ),
                ElevatedButton(
                  onPressed: () => Modular.to.navigate('/test/dog'),
                  child: const Text('Navigate to /test/dog/info'),
                ),
                //Expanded(child: RouterOutlet())
              ],
            ),
        // children: [
        //   ChildRoute('/info', child: (context) => Text("Info")),
        //   ChildRoute('/log', child: (context) => Text("log")),
        // ]
        );

Environment flutter_modular: 6.3.2 provider: ^6.0.0

bandinopla avatar Jan 26 '24 16:01 bandinopla