Reputation: 87
I have a drawer class in common for 3 pages. Here my problem is if i open any list item page in drawer while in main screen its working fine. if i goto some page(say page2 screen) other than main screen, now if i open any list item in drawer it opens the screen but problem is if i press back button it goes to main screen instead of page2 screen.
Drawer class:
class CustomDrawer extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Theme(
data: Theme.of(context).copyWith(
canvasColor: Colors.deepOrangeAccent.withOpacity(0.9), //This will change the drawer background to blue.//other styles
),
child: Drawer(
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left:8.0),
child: ListView(
shrinkWrap: true,
children: <Widget>[
ListTile(
leading: Icon(Icons.event_note,color: Colors.white),
title: Text("Menu",style: TextStyle(color:Colors.white),),
onTap: () {
Navigator.push (
context, MaterialPageRoute(builder(BuildContextcontext)=> Menu()));
},
),
ListTile(
leading: Icon(Icons.person,color: Colors.white),
title: Text("My Profile",style: TextStyle(color:Colors.white),),
onTap: () {
Navigator.push (
context, MaterialPageRoute(builder: (BuildContext context) => MyProfile()));
},
),
],
),
)
],
),
),
);
}
}
Upvotes: 1
Views: 805