getx
getx copied to clipboard
Get.back with closeOverlays doesn't take result
Describe the bug
var foo = Foo();
Get.back(closeOverlays: true, result: foo);
won't take foo
anywhere.
I understand that snackbars might not have a result waiting (or maybe yes?) but the documentation says:
/// currently open snackbar/dialog/bottomsheet AND the current page
we might have a dialog or bottom sheet result waiting (decision taken, name input, etc) and we want to pass that back.
**Reproduction code
void _showBottomSheet() {
Get.bottomSheet<String>(
_buildBottomSheet(),
).then(print);
}
Widget _buildBottomSheet() {
Future.delayed(Duration(seconds: 3)).then((_) {
Get.back(closeOverlays: true, result: "foo");
});
return Container(width: 50, height: 50);
}
void main() {
_showBottomSheet();
}
should print "foo"
but it doesn't.
Getx Version: 4.6.1
Describe on which device you found the bug: All
A little restructuring and removing closeOverlays or setting it to false and it works.
void _showBottomSheet() {
Get.bottomSheet<String>(
_buildBottomSheet(),
).then((val) {
debugPrint(val);
});
}
Widget _buildBottomSheet() {
return Container(
width: Get.width,
height: Get.height * .7,
color: Colors.white,
child: Center(
child: GestureDetector(
onTap: () {
Get.back(result: "foo");
},
child: Text(
'Press',
style: Theme.of(context).textTheme.headline4,
),
),
),
);
}
@aljibbs yup, but it's a workaround for your solution, not a solution itself