Get.back(closeOverlays) needs better documentation
Description Get.back(closeOverlays) states that it will close all open overlays until it hits a screen. in the demonstrated scenario, it will literally close all overlays including the intermediate screens. and i expected it will only close overlays until it hits the first screen.
My suggested solution my suggestion is that it should behave as i expected. or Update the documentation to reflect the current behavior. currently i solved my issue by using double Get.back() instead of Get.back(closeOverlays). but it wasted some of my time to debug it, thinking it was a problem. hopefully this saves someone else time.
Reproduction code
runApp(sandbox());
dynamic sandbox()
{
return GetMaterialApp(
title: 'Getx issue',
debugShowCheckedModeBanner: false,
home: EntryPage());
}
class EntryPage extends StatelessWidget
{
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Entry page'),),
body: Center(
child: RaisedButton(child: Text("open BottomSheet "),onPressed: ()=>Get.bottomSheet(BottomSheet1()),
),
));
}
}
class Screen1 extends StatelessWidget
{
Screen1();
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(child:
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
RaisedButton(child: Text("go to entry page"),onPressed: ()=>Get.off(EntryPage()))
],)
,),
);
}
}
class Screen2 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(child: RaisedButton(child: Text('open dialog '),onPressed: ()=>Get.dialog(Dialog1()),)),
);
}
}
class Dialog1 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Center(child: RaisedButton(child: Text('Get.back(closeOverlays:true)'),onPressed: ()=>Get.back(closeOverlays:true),color: Colors.cyanAccent,));
}
}
class BottomSheet1 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return RaisedButton(child: Text('Go to Screen 2'),onPressed: ()=>Get.to(Screen2()),);
}
}
To Reproduce Steps to reproduce the behavior:
- follow the buttons in the demo
- notice the behavior when clicking Get.back(closeOverlays:true) button
Expected behavior it will only close overlays until it hits the first full screen.
Flutter Version: flutter 1.22.5 stable channel
Getx Version: get: ^3.22.2
Describe on which device you found the bug: android emulator