I've already tried:
@override
void didChangeDependencies() {
super.didChangeDependencies();
Orientation orientation = MediaQuery.of(context).orientation;
(orientation == Orientation.portrait)
? print(orientation)
: Navigator.pop(context);
}
in the _BottomContentState but that gives me an error when I switch the orientation of the device.
Additionally I want the ModalBottomSheet to close if it is open, otherwise no action
You could use an
OrientationBuilder
widget to programatically close your modal bottom sheet.