From 40018431dd81f7497474c2b35f23867a8a11de04 Mon Sep 17 00:00:00 2001 From: Crondung <1922635@stud.hs-mannheim.de> Date: Wed, 15 Feb 2023 14:30:25 +0100 Subject: [PATCH] make appbar title change dynamically --- lib/pages/main_page.dart | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/pages/main_page.dart b/lib/pages/main_page.dart index 48859bd..3241a4c 100644 --- a/lib/pages/main_page.dart +++ b/lib/pages/main_page.dart @@ -14,6 +14,13 @@ class MyHomePage extends StatefulWidget { class MyHomePageState extends State { int _selectedIndex = 2; + final List _titles = [ + 'Stimmung', + 'Schlaf', + 'Timer', + 'Rückfall', + 'Einstellungen' + ]; static const List _widgetOptions = [ MoodPage(), SleepPage(), @@ -29,7 +36,7 @@ class MyHomePageState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: const Text('ZI Rauchentwöhnung')), + appBar: AppBar(title: Text(_titles[_selectedIndex])), body: _widgetOptions.elementAt(_selectedIndex), bottomNavigationBar: NavigationBar( onDestinationSelected: _onItemTapped,