diff options
author | Felipe Erias <felipeerias@igalia.com> | 2021-11-12 12:06:32 +0900 |
---|---|---|
committer | Felipe Erias <felipeerias@igalia.com> | 2021-11-12 12:06:32 +0900 |
commit | 6cdae5992de2b9865a3a05885e91338160243674 (patch) | |
tree | 084dafb4361bb668726c3f54075184ec3aa6c6c6 /lib/homescreen.dart | |
parent | 239ad725cd6e2b64974be4ab3949b38cb32eff7e (diff) |
Home screen buttons navigate to the appropriate section
Diffstat (limited to 'lib/homescreen.dart')
-rw-r--r-- | lib/homescreen.dart | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/homescreen.dart b/lib/homescreen.dart index 232c184..c81a2d5 100644 --- a/lib/homescreen.dart +++ b/lib/homescreen.dart @@ -17,6 +17,12 @@ class Homescreen extends StatefulWidget { class _HomescreenState extends State<Homescreen> { int _selectedIndex = 0; + setNavigationIndex(int index) { + setState(() { + _selectedIndex = index; + }); + } + @override Widget build(BuildContext context) { var screenHeight = MediaQuery.of(context).size.height; @@ -35,9 +41,7 @@ class _HomescreenState extends State<Homescreen> { // leading widget? // trailing widget does not expand to bottom onDestinationSelected: (int index) { - setState(() { - _selectedIndex = index; - }); + setNavigationIndex(index); }, selectedIconTheme: IconTheme.of(context).copyWith( size: iconSize, @@ -93,7 +97,7 @@ class _HomescreenState extends State<Homescreen> { Widget _childForIndex(int selectedIndex) { switch (selectedIndex) { case 0: - return HomePage(); + return HomePage(onSetNavigationIndex: setNavigationIndex); case 1: return DashboardPage(); case 2: |