From 6cdae5992de2b9865a3a05885e91338160243674 Mon Sep 17 00:00:00 2001 From: Felipe Erias Date: Fri, 12 Nov 2021 12:06:32 +0900 Subject: Home screen buttons navigate to the appropriate section --- lib/homescreen.dart | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lib/homescreen.dart') 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 { 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 { // 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 { Widget _childForIndex(int selectedIndex) { switch (selectedIndex) { case 0: - return HomePage(); + return HomePage(onSetNavigationIndex: setNavigationIndex); case 1: return DashboardPage(); case 2: -- cgit 1.2.3-korg