I am trying to achieve a persistent menu (side-bar) in flutter web. I can achieve that as long as all the pages in the app are directly listed as menu items. The problem is I cannot get the nested pages (pages not listed in the side menu but open on some button click from inside another page) to open in the "content area".
I have tried a LOT of stuff from Navigation Rail to GoRouter to different packages for sidebar.
I don't know what code to post here.
My project also uses Getx.
With whatever code I have I can open 1st level pages in the content area but the nested pages load as a new page and the side-bar is lost.
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
///
final MyMenuController menuController = Get.put(MyMenuController());
///
return Scaffold(
appBar: AppBar(
title: const Text('Side Menu Example'),
),
body: Row(
children: [
Expanded(
child: Container(
color: Colors.blue,
child: ListView(
children: [
ListTile(
title: const Text('Page 1'),
selected: menuController.selectedIndex.value == 0,
onTap: () {
menuController.selectTab(0);
},
),
ListTile(
title: const Text('Page 2'),
selected: menuController.selectedIndex.value == 1,
onTap: () {
menuController.selectTab(1);
},
),
ListTile(
title: const Text('Page 3'),
selected: menuController.selectedIndex.value == 2,
onTap: () {
menuController.selectTab(2);
},
),
],
),
),
),
Expanded(
flex: 5,
child: Container(color: Colors.white, child: const SizedBox() //
Obx(
() {
switch (menuController.selectedIndex.value) {
case 0:
return const Page1();
case 1:
return const Page2();
case 2:
return const Page3();
default:
return Container();
return Container();
}
},
),
),
),
],
),
// ),
);
}
}
Just in case somebody wants to say "Show us what you have tried". I have tried a bunch of stuff nothing worked out so far. If you know how to achieve this, please point me in the right direction.