I have two stacked Scaffold
s, a parent and a child. On button press, both Scaffold
s show a popup each from their own context. But no matter what, Navigator.pop
always dismiss the top most popup, ignoring the passed context.
class StateTest extends State<ScreenTest>{
BuildContext parent, child;
@override
Widget build(BuildContext context) => Scaffold(
drawer : Drawer(child: Container()),
body: Builder(builder : (BuildContext context){
this.parent = context;
return Scaffold(
body: Builder(builder : (BuildContext context){
this.child = context;
}),
floatingActionButton: FloatingActionButton(
onPressed: (){
showDialog(context: parent, child: Center(child: Text('PARENT')));
showDialog(context: child, child: Center(child: Text('CHILD')));
Timer(Duration(seconds: 1), () => Navigator.of(parent).pop());
}
),
);
})
);
}
I just want to dismiss popup from specific context.