From 68aadc5119aefa006a86baca204f666ce3d1c453 Mon Sep 17 00:00:00 2001 From: Prasanna Anbazhagan Date: Sun, 31 Dec 2023 20:24:56 +0530 Subject: [PATCH] make collapsible --- lib/ui/pages/main_page.dart | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/lib/ui/pages/main_page.dart b/lib/ui/pages/main_page.dart index 2591b2d..e03908f 100644 --- a/lib/ui/pages/main_page.dart +++ b/lib/ui/pages/main_page.dart @@ -14,6 +14,7 @@ class MainPage extends StatefulWidget { class _MainPageState extends State { var _selectedIndex = 0; + var _isExtended = true; @override Widget build(BuildContext context) { @@ -25,23 +26,31 @@ class _MainPageState extends State { body: SafeArea( child: Row( children: [ - NavigationRail( - extended: true, - onDestinationSelected: (value) { + GestureDetector( + onTap: () { setState(() { - _selectedIndex = value; + _isExtended = !_isExtended; }); }, - destinations: const [ - NavigationRailDestination( - icon: Icon(Icons.bookmark), label: Text('Goals')), - NavigationRailDestination( - icon: Icon(Icons.monetization_on), - label: Text('Investment')), - NavigationRailDestination( - icon: Icon(Icons.local_offer), label: Text('Baskets')), - ], - selectedIndex: _selectedIndex), + child: NavigationRail( + extended: _isExtended, + onDestinationSelected: (value) { + setState(() { + _selectedIndex = value; + }); + }, + destinations: const [ + NavigationRailDestination( + icon: Icon(Icons.bookmark), label: Text('Goals')), + NavigationRailDestination( + icon: Icon(Icons.monetization_on), + label: Text('Investment')), + NavigationRailDestination( + icon: Icon(Icons.local_offer), + label: Text('Baskets')), + ], + selectedIndex: _selectedIndex) + ), const VerticalDivider(thickness: 1, width: 1), Expanded( child: Builder(