body:Container(
//child: IndexedStack(
//index: _selectedIndex,
//children: _items
//)//_items.elementAt(_index),
height: MediaQuery.of(context).size.height*0.25,
margin: EdgeInsets.all(20),
alignment: Alignment.topCenter,
child: IndexedStack(
index: _selectedIndex,
children: [
ElevatedButton(
style: ElevatedButton.styleFrom(
minimumSize: const
Size.fromHeight(50)
),
child: Text('SUBUH'),
onPressed: (){
Navigator.push(context,
MaterialPageRoute(
builder: (context) => halamansubuh(
)
),
ElevatedButton(
style: ElevatedButton.styleFrom(
minimumSize: const
Size.fromHeight(100)
),
child: Text('ZUHUR'),
onPressed: (){
Navigator.push(context,
MaterialPageRoute(
builder: (context) => halamanzuhur(title: 'halamanzuhur', desc: 'halamanzuhur',
)
));
}
),
);
}
)
CodePudding user response:
Navigator.push needs 2 arguments. you are giving it 3. it needs a context and a route. You are giving it a 3rd arguement, the ElevatedButton. It doesn't belong there,
Maybe you want that ElevatedButton instead of the halamansubuh() ?
CodePudding user response:
Replace your code with this code
Container(
//child: IndexedStack(
//index: _selectedIndex,
//children: _items
//)//_items.elementAt(_index),
height: MediaQuery.of(context).size.height*0.25,
margin: EdgeInsets.all(20),
alignment: Alignment.topCenter,
child: IndexedStack(
index: _selectedIndex,
children: [
ElevatedButton(
style: ElevatedButton.styleFrom(
minimumSize: const
Size.fromHeight(50)
),
child: Text('SUBUH'),
onPressed: (){
Navigator.push(context,
MaterialPageRoute(
builder: (context) => halamansubuh(
)
),);}),
ElevatedButton(
style: ElevatedButton.styleFrom(
minimumSize: const
Size.fromHeight(100)
),
child: Text('ZUHUR'),
onPressed: (){
Navigator.push(context,
MaterialPageRoute(
builder: (context) => halamanzuhur(title: 'halamanzuhur', desc: 'halamanzuhur',
)
));
}
),
]
));