make appbar title change dynamically
parent
fade190d08
commit
40018431dd
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue