Reputation: 161
So I have a Column like this and I would like to switch between PageOne(), PageTwo(), PageThree() here with transition
on the comment i've written on the code, how exactly do I do that?
Column(
children: <Widget>[
Row(
children:[
Text("Test")
]
),
// I would like to switch between PageOne(), PageTwo(), PageThree() here with transition left to right or vice versa
]
)
I tried the code below in onTap of a button
and it does not work. I've received error saying No material widget found. List tile widgets require a Material ancestor widget.
Widget resSlide = PageOne(); //default page
//Inside onTap of a button
Navigator.push(
context,
PageTransition(
type: PageTransitionType.leftToRight,
child: dataIndex == 1 ? resSlide = PageOne() : dataIndex == 2 ? resSlide = PageTwo() : resSlide = PageThree())
);
Upvotes: 0
Views: 368
Reputation: 175
You can use IndexedStack to switch between these pages . Every page should have specific index . Please check this url : https://o7planning.org/13227/flutter-indexedstack
Upvotes: 1