when i pull the drawer and select a page to navigate to it is like create a new instance of that, for example if i clicked on the same page 4 times it shows the animation of opening a new page 4 times and same when i press the back button of the phone.
new ListTile(
leading: Icon(Icons.home),
title: new Text("Home"),
onTap: () {
Navigator.pop(ctxt);
Navigator.push(
ctxt, new MaterialPageRoute(builder: (ctxt) => MyHomePage()));
},
here's the drawer file i'm using in all the pages
class DrawerOnly extends StatelessWidget {
@override
Widget build(BuildContext ctxt) {
return new Drawer(
child: new ListView(
children: <Widget>[
new UserAccountsDrawerHeader(
accountName: new Text('Fethi'),
accountEmail: new Text('Myemail@Mail.com'),
currentAccountPicture: new CircleAvatar(
backgroundImage: new NetworkImage('http://i.pravatar.cc/300'),
),
),
new ListTile(
leading: Icon(Icons.home),
title: new Text("Home"),
onTap: () {
Navigator.pushReplacement(
ctxt, new MaterialPageRoute(builder: (ctxt) => MyHomePage()));
},
),
new ListTile(
leading: Icon(Icons.note),
title: new Text("ADD Notes"),
onTap: () {
Navigator.pushReplacement(
ctxt, new MaterialPageRoute(builder: (ctxt) => EditNote()));
},
),
],
),
);
} }