I am making a sales app, where I use a drawer to move between screens using the Navigator commands, and found the following situation
1 - When opening the app it enters on the main screen where the sale is made
2 - I select two products to sell
3 - right after I leave the sales screen that has the two products and go to customers screen
4 - now I need to go back to the sales screen, and the two products that had already been selected should still be there
Right, in this part 4, using the key to go back on the cell phone it returns a screen and goes to this sales screen (with the two products there), but if I go in the drawer and select the option to go to the sales screen, how do I search this screen at the beginning of the stack instead of creating a new sales screen (which comes empty without the two products). I want this because if it is only one screen on top of the stack, no problem, the user presses to go back and that's it, but if there are for instance 5 or 6 screens on top, it is a great wear and tear for the user to have to go back everything, pressing several times on the back, to not lose what was already made on the sales screen. Is there any navigator command that does this? I've already looked for some things, but I didn't find something that helps me.
Drawer code
@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return MultiLevelDrawer(
backgroundColor: Color(0xfff0f3f4),
rippleColor: Colors.white,
subMenuBackgroundColor: Color(0xfff0f3f4),
divisionColor: Colors.grey,
header: Container(
height: size.height * 0.25,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Image.asset(
"Imagens/ACMIL_CIRCULAR.png",
width: 100,
height: 100,
),
SizedBox(
height: 10,
),
Text("Usuario : Iury")
],
)),
),
children: [
MLMenuItem(
leading: Icon(Icons.person),
trailing: Icon(Icons.arrow_right),
content: Text(
"Cadastro",
),
subMenuItems: [
MLSubmenu(
onClick: () {
Navigator.of(context).pop();
Navigator.of(context).push(MaterialPageRoute(builder: (context) => ClientePesquisa("",0,"",0)));
},
submenuContent: Text("Cliente")),
MLSubmenu(onClick: () {
Navigator.of(context).pop();
Navigator.of(context).push(MaterialPageRoute(builder: (context) => ProdutoPesquisa(0,"",0,0,"")));
},
submenuContent: Text("Produto")),
MLSubmenu(onClick: () {
Navigator.of(context).pop();
Navigator.of(context).push(MaterialPageRoute(builder: (context) => VendedorPesquisa(0,"",0)));
},
submenuContent: Text("Vendedor")),
MLSubmenu(onClick: () {
Navigator.of(context).pop();
Navigator.of(context).push(MaterialPageRoute(builder: (context) => CondPGTOPesquisa("","","","")));
},
submenuContent: Text("Cond. de Pagamento")),
MLSubmenu(onClick: () {
Navigator.of(context).pop();
Navigator.of(context).push(MaterialPageRoute(builder: (context) => FormaPGTOPesquisa(0,"")));
},
submenuContent: Text("Forma de Pagamento")),
],
onClick: () {}),
MLMenuItem(
leading: Icon(Icons.local_grocery_store),
content: Text("Pré-Venda"),
onClick: () {
Navigator.of(context).push(MaterialPageRoute(builder: (context) => PedidoVenda()));
},
),
MLMenuItem(
leading: Icon(Icons.settings),
content: Text("Configura??o"),
onClick: () {
Navigator.of(context).push(MaterialPageRoute(builder: (context) => Configuracao()));
}
)],
);
}
}