I am very new to Flutter but coming from an Angular background here. Say I want to build a BaseFrame for my app, and depending on the routing, I want to change the INSIDE of that BaseFrame. I don't understand how this would work?
In Angular it would be something like:
'/page-one': PageOne(),
'/page-two': PageTwo(), children: [
'/part-1': Part1(),
'/part-2': Part2(),
];
And in this case, if you navigate to /page-two/part-1
then it would load PageTwo()
, and it would load Part1()
wherever you specified <app-route></app-route>
on PageTwo()
. I don't understand how one would do this in Flutter because in Flutter it seems like you can only ever have a single flat route in your main.dart (in your MaterialApp
builder)
The best thing I can think of is to have a variable on PageTwo()
, and have a type of switch statement:
switch (subPage) {
case '/part-1':
return Part1();
case '/part-2':
return Part2();
}
But this seems like a crappy solution. You also now have the problem of fixing animations etc yourself (because the MaterialApp
won't help you here automatically).
Here is something about this but this seems super complicated for a noob. Is this really the right/only way to do this: Nesting routes with flutter