make appbar title change dynamically

main
Julian Gegner 2023-02-15 14:30:25 +01:00
parent fade190d08
commit 40018431dd
1 changed files with 8 additions and 1 deletions

View File

@ -14,6 +14,13 @@ class MyHomePage extends StatefulWidget {
class MyHomePageState extends State<MyHomePage> {
int _selectedIndex = 2;
final List<String> _titles = [
'Stimmung',
'Schlaf',
'Timer',
'Rückfall',
'Einstellungen'
];
static const List<Widget> _widgetOptions = <Widget>[
MoodPage(),
SleepPage(),
@ -29,7 +36,7 @@ class MyHomePageState extends State<MyHomePage> {
@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,